Solved Keeping a window on top
-
In my app, my main.qml file instantiates the Loader. I set my startup page as the source. I then attempt to initiate a socket connection. I've defined a modal window to inform the user of any problems making the connection. The problem is, if the connection fails and the dialog box pops up before the startup screen is rendered, it is quickly pushed behind the startup screen.
Is there a way to force a window to always be on top? I would have thought setting the window to Qt.ApplicationModal would have done it, but that's not the case.
Thanks!
-
Have you tried:
flags: Qt.WindowStaysOnTopHint
?
-
Yes, that doesn't seem to work either. I see the dialog briefly, and then the startup screen blocks it out. Because the dialog is application modal, I cannot interact with the startup screen at all, even though I can't see the dialog.
-
I've solved the problem. The issue appears to be one of association. Most our pages are not actual Qt Window objects, but rather rectangle objects with various other controls and objects within them. The dialog I was attempting to create is a QML Window object. Without an association to the main application window, there was nothing to tell the QML engine how to handle the dialog in context of the main window. It then became simply a question of timing.
By utilizing a small javascript function, I used the Component.createObject() method which allows me to set the parent window of any created dialog. By doing so, all of the expected behaviors were correctly applied to the dialog, in the proper context of the main application window.
-
Thanks for sharing the solution.