Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Press Escape key in QmessageBox Close Parent Window
Qt 6.11 is out! See what's new in the release blog

Press Escape key in QmessageBox Close Parent Window

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    guru
    wrote on last edited by
    #1

    Hi,
    I'm using Qt5.1.0 in Ubuntu 13.04. The problem was I developed a Dialog based Application, in that app I had a warning message box with ok button and message box was modal. when message box appeared, I click Escape key without pressing of ok button to close message box, both message box and parent were closed. whats wrong in message box... any suggesstions please..

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seba84
      wrote on last edited by
      #2

      By default the Escape key closes the Dialog windows on Qt.
      But did you get any error? Why is this a problem?

      If you want to eliminate this behaviour you should override the keyPressEvent function on your Dialog class the following:
      @MyDialog::keyPressEvent(QKeyEvent *e) {
      if(e->key() != Qt::Key_Escape)
      QDialog::keyPressEvent(e);
      }@

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guru
        wrote on last edited by
        #3

        Thanks, Its works.. But I already use keypressevent in eventfilter, why that didn't work..

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved