PDA

View Full Version : Qt5 and modal windows



Carlsberg
5th May 2013, 18:58
I have a QFrame displayed as a subwindow (so it doesn't have a taskbar button) and also modal, with no parent.

In Qt4, when pressing on the application taskbar button the frame is always on top of the application. Also this happens when choosing another application then coming back to my application.

In Qt5 however, when I press on my application button, the main window comes on top, hiding the modal frame, making the application unusable, since the modal frame is behind, so I can only close it from the task manager.

This is what I'm using:


setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);

setWindowModality(Qt::ApplicationModal);

I'm absolutely sure it's a Qt5 problem, because I use the exact same code with both versions

Any idea how can I make this thing behave sanely in Qt5?

d_stranz
5th May 2013, 19:15
Maybe you also need Qt::WindowStaysOnTopHint. Or simply give your dialog a parent - being parentless is the root cause of your problem; if it were a child of your main widget, it would always be on top.

Carlsberg
5th May 2013, 20:19
I've tried Qt::WindowStaysOnTopHint too, what that does is making the frame to stay on top of everything, not only my application. Also, it can't have a parent, because then it will be limited to the parent. The root cause i Qt5, but I have no idea why...

Added after 39 minutes:

Ok, I've added a parent and the flag Qt::Window and it works. Thanks :)

wysota
6th May 2013, 09:42
It should be enough to derive your window from QDialog instead of QWidget (e.g. put a QFrame in QDialog).