有時QtCreator無法識別某些類型/屬性,主要是不存在的Qt4.x的,但是,這並不意味着你不能使用它們,所以是的,「窗口」是未知的,就像屬性「抗鋸齒」,「fontSizeMode」或「積極」是的,但你可以使用它們,這裏是QtQuick.Window 2.0使用的例子:
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
id: win1;
width: 320;
height: 240;
visible: true;
color: "yellow";
title: "First Window";
Text {
anchors.centerIn: parent;
text: "First Window";
Text {
id: statusText;
text: "second window is " + (win2.visible ? "visible" : "invisible");
anchors.top: parent.bottom;
anchors.horizontalCenter: parent.horizontalCenter;
}
}
MouseArea {
anchors.fill: parent;
onClicked: { win2.visible = !win2.visible; }
}
Window {
id: win2;
width: win1.width;
height: win1.height;
x: win1.x + win1.width;
y: win1.y;
color: "green";
title: "Second Window";
Rectangle {
anchors.fill: parent
anchors.margins: 10
Text {
anchors.centerIn: parent
text: "Second Window"
}
}
}
}
你只需要有一個窗口項目的根對象,並且可以嵌入其他窗口項目。
Qt 5.0在那裏。那個試過了嗎? – sebasgo
是的,我試過了。但它仍然不起作用。 – Dominik