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] Closing QDialog with ESC
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Closing QDialog with ESC

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • M Offline
    M Offline
    miguelg
    wrote on last edited by
    #1

    I have overridden closeEvent´ in a QDialog-derived class and am able to capture close´ events when, for instance, the user engages the cancel button. However, if the user hits ESC instead, `closeEvent´ isn't triggered and thus am unable to capture it and carry out needed processing.

    It seems hitting ESC on a dialog invokes a different mechanism to `close´. How do I trap closing of dialogs via ESC?

    1 Reply Last reply
    0
    • tomasz3dkT Offline
      tomasz3dkT Offline
      tomasz3dk
      wrote on last edited by
      #2

      It happens like this, because by hitting ESC you call reject slot on QDialog, and QDialog is only hidden. I think, that solution for this will be create a QShortcut in your QDialog-derived class with ESC sequence, and connect this shortcut's activated signal with dialog's close slot.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miguelg
        wrote on last edited by
        #3

        Hmm, I see now. Reject and the hide behaviour is key to understanding what's happening. Will investigate further and come up with a solution.

        Thanks for the very helpful pointers!

        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