Reputation: 4484
Window {
Window {
id: childWindow
}
}
I have a QML like this, and childWindow
icon does not display in task bar when the window is shown. My environment is Windows 7.
In a CPP setting I think it would suffice to set parent of childWindow
to 0
to have both windows to be top level.
But how to do that in QML?
Upvotes: 3
Views: 878
Reputation: 13691
If you create an Object in QML like this, the parent is automatically set, and you can only change the visual parent by using the parent
-property.
To have it otherwise, you might do one of the following:
The former can be done as follows:
property Window mySecondWindow: secondWindowComponent.createObject(null)
Component {
id: secondWindowComponent
Window {
...
}
}
To destroy this, call mySecondWindow.destroy()
. If you only delete the reference, the JS GC will eventually take care of it. If it does not fail.
The latter can be done by adding something like that to your main.cpp
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Upvotes: 2
Reputation: 12864
You can do something like that:
Item
{
Window
{
id: wnd1
width: 200
height: 200
title: "Window1"
visible: true
onClosing: wnd2.close();
}
Window
{
id: wnd2
width: 200
height: 200
title: "Window2"
visible: true
}
}
Note that when wnd1
is closed (main/root window) also the second one gets closed onClosing
handle ensuring the correct - or expected - behaviour on main window closing.
Upvotes: 2