先上原始碼
LeftTopPage.qml
import QtQuick 2.5
import QtQuick.Controls 1.4
import Material 0.2 as Mater
Rectangle {
id: topPage;
// width: 300;
// height: 80;
color: "transparent";
property alias imageSource: image.source;
property string name: "張三";
property string desc: "ajajajajajaj";
Row {
id: row;
anchors.verticalCenter: parent.verticalCenter;
anchors.left: parent.left;
anchors.leftMargin: 10;
spacing: 10;
Rectangle{
id: faceState;
width: topPage.height - 10;
height: topPage.height - 10;
color: "transparent";
Rectangle {
id:imageRect;
anchors.centerIn: faceState;
width: faceState.height;
height: faceState.height;
radius: faceState.height / 2;
color: "transparent"
ImageCircle {
id: image;
anchors.fill: parent;
border: 1;
source: "http://img5.duitang.com/uploads/item/201410/27/20141027124824_e4hjS.png";
}
}
Rectangle {
id: userState;
anchors.bottom: faceState.bottom;
anchors.right: parent.right;
color: "transparent";
width: faceState.height / 4;
height: faceState.height / 4;
radius: faceState.height / 8;
ImageCircle {
id: tipImage;
anchors.fill: parent;
border: 0;
source: "qrc:/state/onLine.png";
}
MouseArea {
id: mouseArea;
anchors.fill: parent;
onClicked: {
menuState.popup();
}
}
}
}
Column {
id: column;
spacing: 10;
Text {
id: userName;
width: topPage.width * 2 / 3;
color: Mater.Palette.colors.red["600"];
font.pixelSize: Mater.Units.dp(32);
font.bold: true;
font.family: "楷體";
text: name;
}
Text {
id: description;
width: topPage.width * 2 / 3;
font.pixelSize: Mater.Units.dp(20);
elide: Text.ElideRight;
font.family: "楷體";
text: desc;
MouseArea {
id: mouseAreaText;
anchors.fill: parent;
hoverEnabled: true;
}
Mater.Tooltip {
id: toolTip;
mouseArea: mouseAreaText;
text: desc;
}
}
}
}
Menu {
id: menuState;
MenuItem{
text: "在線";
iconName: "onLine";
iconSource: "qrc:/state/onLine.png";
onTriggered: {
tipImage.source = "qrc:/state/onLine.png";
tipImage.repaintUI();
userState.color = "transparent";
}
}
MenuItem{
text: "忙碌";
iconName: "busy";
iconSource: "qrc:/state/busy.png";
onTriggered: {
tipImage.source = iconSource;
tipImage.repaintUI();
userState.color = "transparent";
}
}
MenuItem{
text: "離線";
iconName: "offLine";
iconSource: "qrc:/state/offLine.png";
onTriggered: {
tipImage.source = iconSource;
tipImage.repaintUI();
userState.color = "transparent";
}
}
MenuItem{
text: "隱身";
iconName: "hide";
iconSource: "qrc:/state/hide.png";
onTriggered: {
tipImage.source = iconSource;
tipImage.repaintUI();
userState.color = "transparent";
}
}
}
}
單獨是使用qmlscene 來執行這個頁面選單沒問題,放在一個Window元素中也沒問題,可以只要
登陸界面的Window元素視窗在嵌套一個帶有LeftTopPage.qml元素的Window元素視窗登陸后隱藏第一個Window視窗元素
顯示第二個Window元素視窗后LeftTopPage.qml這個頁面的選單只要點擊 后就會崩潰,請各位大大幫忙解決,我才開始使用QML
uj5u.com熱心網友回復:
老兄你的這個原始碼還有沒參考一下轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/143165.html
標籤:Qt
上一篇:安卓開發報錯 Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUN
