3

最近、Mac OS X 用の Qt5 RC2 をインストールし、いくつかの QML アプリケーションの開発を開始しました。新しい要素を見た後、特に Window と Screen 要素を試してみたいと思いました。(http://qt-project.org/doc/qt-5.0/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html)

したがって、次のようにファイルの先頭にインポートを設定します。

QtQuick 2.0
をインポートする QtQuick.Window 2.0 をインポートする

インポートは見つかりましたが、ウィンドウもスクリーンも使用できません。Screen または Window と入力するたびに、「不明なコンポーネント (M300)」というエラーが表示されます。

誰が問題が何であるか考えていますか?

4

1 に答える 1

5

QtCreator は、主に Qt4.x に存在しなかったタイプ/プロパティを認識しない場合がありますが、それはそれらを使用できないという意味ではありません。したがって、「ウィンドウ」はプロパティ「アンチエイリアシング」と同様に不明です。 、 'fontSizeMode' または 'active' は使用できますが、使用できます。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"
            }
        }
    }
}

Window アイテムをルート オブジェクトとして持つだけで、他の Window アイテムをそこに埋め込むことができます。

于 2013-03-27T10:09:19.557 に答える