How to make a non-modal Dialog window be always on top?

Viewed 6447

I am using an instance of a Dialog {} in my application to display a small controller window that the user can interact with to affect the functions in the main window (sort of a remote control). I can make this Dialog modal (modality: Qt.WindowModal or modality: Qt.ApplicationModal) or I can make it non-modal with modality: Qt.NonModal.

My problem is that I need to make it non-modal but be always on top of the main window. If I use Qt.NonModal I can still click on the main form but then my Dialog goes behind it. The Dialog class does not seem to have a flags: property, so I can't just set it to Qt.WindowsStaysOnTopHint.

Is there any way to set the flags of a Dialog like this purely from the QML side? Or is it possible to write a simple utility method in c++ that I could call from my Dialog's Component.onCompleted: and pass in the dialog to set its windows flags there?

Update: to illustrate what I'm talking about, here is my dialog on top of my main window:

enter image description here

Here is my dialog underneath my main window:

enter image description here

I want my dialog to not go underneath my main window like this, but I still want to be able to click on and interact with my main window. In other words, I want my dialog to be non-modal, but always-on-top.

3 Answers
Related