Results 1 to 3 of 3

Thread: QDialog - how to stop hide on "ESC"?

  1. #1
    Join Date
    Jul 2007
    Posts
    56
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QDialog - how to stop hide on "ESC"?

    I have a modal dialog box that I need to be displayed until I'm finished some processing. However the user can close/hide the dialog by pressing the "ESC" key. How can I override this default behavior in QDialog so I can stop it from doing this?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog - how to stop hide on "ESC"?

    If the user presses the Esc key in a dialog, QDialog::reject() will be called. You can reimplement that function to do nothing under certain circumstances:
    Qt Code:
    1. void MyDialog::reject()
    2. {
    3. if (itsOkToClose)
    4. {
    5. QDialog::reject();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    will49 (27th May 2008)

  4. #3
    Join Date
    Jul 2007
    Posts
    56
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog - how to stop hide on "ESC"?

    Great. That worked.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.