Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Get the application's widgets in correct Z-Order?
How do I get the application's widgets in the correct Z-Order?
Based on "this suggestion":https://bugreports.qt-project.org/browse/QTBUG-2043?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel QApplication::topLevelWidgets() is probably not the answer.
What do you mean? Do the widgets appear in wrong order for you? Or maybe you only want to read the widgets in ascending/ descending order?
If the second option is what you're after, then it should be enough to follow the parent-child tree. The widgets on top are the leaves in that tree, the root is the main window.
Yes, I want to know which windows are in front, and which are behind.
First, an application can have multiple top-level widgets. In which order are they?
Second, among sibling widgets how do I get the order?
All top level widgets have no parent, so you can check for (parent == 0). Or you can use "QWidget::isWindow().":http://doc.qt.io/qt-5/qwidget.html#isWindow
Siblings: they are on the same level, so they have the same equivalent of Z value. At least that is what I suspect.
However, in both cases you see sibling windows (whether they are top level or not) in a defined z-order: While I type this, my browser window is on top of my Qt Creator window, although both are system-wide top-level windows. Same goes for windows in MDI applications, non-modal dialog, you name it. There is always a defined order in which windows are drawn.
I can see that Qt cannot deliver this information for other application windows. But within my application, I'd like to know whether dialog A is currently before or behind dialog B.
[quote author="Asperamanca" date="1418913635"]I can see that Qt cannot deliver this information for other application windows. But within my application, I'd like to know whether dialog A is currently before or behind dialog B.[/quote]
Indeed, I don't think there are APIs for that in Qt, but I might now know about something.