PDA

View Full Version : QDialogs are always on top - why?



Maximka
21st February 2010, 12:57
Hi,
I have an application employing a QMainWindow object. There is also an object inherited from QDialog. On pressing certain key this dialog pops up in non-modal mode. But anyway it stays always on top, covering the main window, so I have always to move it aside. I tried to set in the constructor it's windowFlags (~Qt::WindowStaysOnTopHint) but it didn't help. How to make it going behind if focus is passed to the main window?

Lykurg
21st February 2010, 14:39
If your main window is not the parent of your dialog, you should be able to put the dialog behind the window.

Maximka
21st February 2010, 15:32
Ok, that's it, thanks.
But I wonder how should I make it if some dialogs have the main window as the parent? (e.g. to pass QKeyEvents up to the parent with event->ignore() )

codeslicer
21st February 2010, 15:40
That's strange, have you tried messing with the various window hints? Try
setWindowFlags(Qt::CustomizeWindowHint | Qt::Dialog);

Lykurg
21st February 2010, 16:40
But I wonder how should I make it if some dialogs have the main window as the parent? (e.g. to pass QKeyEvents up to the parent with event->ignore() )I haven't had such a case before, but spontaneously I think of: Storing a pointer to your main window in the dialog and then calling QCoreApplication::sendEvent() or QCoreApplication::notify().