[Interest] QWindow::setTransientParent fails on windows
Rutledge Shawn
Shawn.Rutledge at digia.com
Fri Sep 27 16:06:59 CEST 2013
On 27 Sep 2013, at 10:50 AM, Roland Winklmeier wrote:
> In the mean time I found some other weird stuff. I did some tests with QML windows:
>
> ApplicationWindow {
> id: mainWindow
> title: "My MainWindow"
> width: 640
> height: 480
>
> Button {
> text: "Child"
> onClicked: childWindow.visible = !childWindow.visible
> }
>
> Window {
> id: childWindow
> visible: true
> }
> }
>
> childWindow should have the parent mainWindow from the beginning. But it isnt. I have to manually set the visibility to false and open it via the button or close and open it with the button. Doing this will change it to act like a proper child window. I guess this is a bug in Qt.
These kinds of problems are because of initialization order: the inner window is created (and made visible, because it's declared that way) before the outer one is, so it cannot become transient for the outer window. Hopefully we can invent a real fix for that, but in the mean time you can force the order in which they become visible by taking out any visible: true declarations and adding this to the outer window:
Component.onCompleted: { mainWindow.visible = true; childWindow.visible = true }
Or as you say, the user can initiate showing the transient window. A transient popup dialog is usually a response to something the user did, or something that happened asynchronously; but why would you write an app that interrupts you immediately with a transient popup before you do anything? I was hoping such situations would be rare, except in writing test code to make sure that multiple windows work OK. ;-)
More information about the Interest
mailing list