Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qml windows appearance



  • Hi all!

    I have a main window of my app. Then, I want to show some non-modal sub-window.

    It should be shown always above the main window of my app, but not above all windows on desktop, and it should minimize/hide when main window is minimized.

    When I use flags: Qt.Dialog | Qt.WindowStaysOnTopHint for sub-window, it is shown always above the main window, which is what I want... But there are side effects, e.g. with that flags my sub-window is shown:

    • above all other windows in the system.
    • above ongoing MessageDialogs and FileDialogs of my app.

    Tha latter is a main trouble. Because user might never see some MessageDialog. And in case it is app-modal, the whole app become blocked! :-/ Same trouble for FileDialog - it is comfortless to choose files when FileDialog is covered by some other window.

    Could you please suggest me how to configure my qml sub-window to eliminate stated side effects? I even may call some c++ code, even specific to Windows, to achieve the desired behaviour.

    Many thanks a lot. My Qt version is 5.3.1



  • I found the root of the problem.

    Sub-window objects were defined inside MenuBar object. Sitting there, they were unable to find transient parent window (e.g main window of the app), and behaved like ordinal top-level windows, same as main window.

    I checked 2 cases: MenuBar is declared as a children inside some item inside main window, and as a property value. In both cases transient parent window was not founded. It seems MenuBar is a some kind of special object which breaks the transient parent search algorithm.

    The solution was to place sub-window objects as child objects to some other better item, probably right inside main window.


Log in to reply