I had a similar problem to this for a Qt Quick application. I don’t think there’s a Qt specific solution to it on Windows. What I ended up doing is dynamically changing the transient parent of the windows to maintain a particular z-order.
The main window would be the base parent, then when the top level windows become active I change their transient parent to the mid level ones and alter the logic to fit our need. I achieved this with an attached type that exposes a property to specify which order the window should be in and an event filter to watch for window events. Regards, Furkan Üzümcü On Apr 24, 2024 at 10:18 -0400, sivan nanthiran <nanthiran2...@gmail.com>, wrote: > Hi all, > > I am trying to create a dual screen application which should support 3 levels > (z-order) of windows/dialogs. Each level of widgets should be preserved at > any given time. > > At the base level, a main widget (MainWidget) and an aux dialog (AuxDialog) > with MainWidget as its parent. These 2 widgets are ensured that they won't > overlap each other as the geometry is handled at all times. > > At the mid level, several dialogs can be opened by clicking buttons in the > main/aux widget. This dialog is created with Qt::Tool flag and MainWidget as > its parent. > > The highest level is a modal dialog that can be opened by mid level dialogs > or the base level widgets. > > > MainWidget mainWidget; > > AuxDialog auxDialog(mainWidget); > > MidLevelDialog dlg (Qt::Tool, mainWidget); > > QDialog dlg; // modal dialog using ::exec() > > The following implementation works in MacOS as expected. However, in Windows, > midLevel dialog can get behind the Aux dialog. > > I have tried the following steps, but it's still not working: > a) Add Qt::WindowStaysOnTopHint to the midLevelDialog on top of Qt::Tool. > This causes the modal dialog to go behind midLevelDialog. > b) Create midLevelDialog with AuxDialog as the parent instead of MainWidget. > Although this works, I still think it should not be this way. Furthermore, in > reality, the AuxDialog may/may not be created, and might get deleted midway. > c) Create modal dialog with midLevel dialog as the parent. But this is not > feasible as there can be several midLevel dialogs opened at the same time and > only one can be parent. > > Could anyone please advice on how to prevent the dialog/widget from getting > into the wrong z-order. > > Regards, > Sivan > _______________________________________________ > Interest mailing list > Interest@qt-project.org > https://lists.qt-project.org/listinfo/interest
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest