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. Escape in QDialog works only in modal mode?

Escape in QDialog works only in modal mode?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 522 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.
  • Aleksey_KA Offline
    Aleksey_KA Offline
    Aleksey_K
    wrote on last edited by
    #1

    Esc does not work for my dialog in non-modal mode, event going to underlying window. Only adding

    setWindowModality(Qt::WindowModal);
    

    to the dialog on creation makes the Esc key work and calls the reject() slot. Is it normal or possible to Esc in/from non-modal dialog?

    1 Reply Last reply
    0
    • Aleksey_KA Offline
      Aleksey_KA Offline
      Aleksey_K
      wrote on last edited by
      #2

      Changed

      dialog->show();
      

      call to

      // Shows the dialog as a modal dialog, blocking until the user closes it.
      dialog->exec();
      

      Works fine for now. Seems the only way to catch event in the dialog, non-modal does not allow this or use key event filter as mentioned in another answer: https://stackoverflow.com/a/49072065/630169

      1 Reply Last reply
      1

      • Login

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