[Interest] [QML] How to create a sub Window for Window {...}

Yuchen Deng loaden at gmail.com
Sun Jun 1 13:25:42 CEST 2014


hi, list! I have to ask for help because I can't create an sub window on
Window {...}.
I've tried some days, after Google still can't solved my problem.

main.qml

> import QtQuick 2.2
> import QtQuick.Window 2.1
> Window {
>     id: mainWindow
>     visible: true
>     width: 760; height: 520
>     color: "red"
>     property variant win;  // you can hold this as a reference..
>     Text {
>         text: "Click here to open sub window 2!"
>         anchors.centerIn: parent
>     }
>     Window {
>         id: subWindow_1
>         width: 555
>         height: 333
>         visible: true
>         flags: Qt.SubWindow
>     }
>     MouseArea {
>         anchors.fill: parent
>         onClicked: {
>             var component = Qt.createComponent("subwindow2.qml");
>             win = component.createObject(mainWindow);
>             win.show();
>         }
>     }
> }


subwindow2.qml

> import QtQuick 2.2
> import QtQuick.Window 2.1
> Window {
>     id: subWindow_2
>     visible: true
>     width: 500; height: 300
>     color: "blue"
>     flags: Qt.SubWindow
>     Rectangle {
>         anchors.fill: parent
>         color: "lightGrey"
>         Text {
>             anchors.centerIn: parent
>             text: "Sub Window 2"
>         }
>     }
> }



See the code, it's can open two window, But can't open as sub window in
parent.
Any help / tips are very welcome!
Thanks you!
-- 
Best Regards
Yuchen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140601/06da2ac2/attachment.html>


More information about the Interest mailing list