PDA

View Full Version : Dialog closes on pressing Esc key?



vishal.chauhan
3rd July 2008, 07:19
Hi All,

I am using Qt 4.3.3 on my Mac.
I have a dialog and when I press the Esc key the dialog get closed.
So how should I avoid this? that is the dialog should not closed on pressing Esc key.

Thanks.

MrShahi
3rd July 2008, 07:33
what did you set Qt::WindowFlags for that dialog ,check it ....................;)

vishal.chauhan
3rd July 2008, 07:39
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);

MrShahi
3rd July 2008, 07:51
Simply set its window Flag Qt::Window, I hope it help you,
you can also prevent your escape key event by explicitly change its event using keyPressEevnt(QKeyEvent *event).........;)

vishal.chauhan
3rd July 2008, 07:56
Thanks for the reply.

Actually it does not make any difference when I use Qt::Windows flag but I will try out second method of changing the keyPressEvent.

vishal.chauhan
3rd July 2008, 09:25
Yes the key event method does work.
Thanks.

jpn
3rd July 2008, 09:53
See thread QDialog - how to stop hide on "ESC"? (http://www.qtcentre.org/forum/f-qt-programming-2/t-qdialog-how-to-stop-hide-on-esc-13875.html)