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. [SOLVED] QDialog::closeEvent not fired by Esc-Key
QtWS25 Last Chance

[SOLVED] QDialog::closeEvent not fired by Esc-Key

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.1k Views
  • 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.
  • Andy314A Offline
    Andy314A Offline
    Andy314
    wrote on last edited by Andy314
    #1

    Hello !
    I have subclassed the QDialog and need a preprocessing before a Window closes. It is a modal dialog. I found out that the QDialog::close() and the click on the window X Button fires the closeEvent.

    But pessing the Esc-Key does not fire the event.

    Why that ?

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hitting Esc is equivalent to calling reject().
      accept() and reject() call done() with appropriate error codes.
      Neither of these close() the window in the closeEvent sense, they merely hide() it.

      Pressing the "X" button calls close(). Calling close() generates a close event.

      As stated in the docs you should implement accept(), reject() or done() to do any custom closing behavior. closeEvent should only be used to store the dialog position if needed.

      1 Reply Last reply
      2

      • Login

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