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] Preventing QDialog from losing focus

[SOLVED] Preventing QDialog from losing focus

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

    Hi,

    I have a QMainWindow that opens a QDialog window, is it possible to stop the QDialog from losing focus when you click on anything but the dialog? What I'm trying to achieve is kind of like windows when a dialog is open and you click outside of the dialog it flashes and rejects input but remains in focus.

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      That is the behaviour of a modal dialog. You get that by calling QDialog::exec() rather than show()

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chrisw01
        wrote on last edited by
        #3

        Thanks, I think I figured it out, you have to call setWindowModality(Qt::ApplicationModel); on the created dialog.

        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