Search code examples
c++qtqt5always-on-top

Window on top of another window?


I want one window to stay above my MainWindow so I use this->setWindowFlags(Qt::WindowStaysOnTopHint); This makes the window stay on top of EVERY window (also from other applications). Also it is above QMessageBox Windows and blocks them. I want them to appear on top of that window.

How can I do that?


Solution

  • You don't need to set WindowStaysOnTopHint flag to force your dialog stay on top of main window. Just set main window as the parent of the dialog when instantiating it in the constructor of main window like :

    dialog = new MyDialog(this);