[Interest] How to implement 3 level windows in Qt (Windows)

sivan nanthiran nanthiran2005 at gmail.com
Wed Apr 24 16:17:31 CEST 2024


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240424/1d4cb2bb/attachment.htm>


More information about the Interest mailing list