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. Modal QDialog without exec()?
Qt 6.11 is out! See what's new in the release blog

Modal QDialog without exec()?

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

    The QDialog::exec() doc says: "Avoid using this function; instead, use open()."

    Does this mean: avoid modal dialogs for good, always use modeless dialogs?

    Or is there recommended way to run a modal dialog starting with open()?

    JonBJ 1 Reply Last reply
    0
    • J Joachim W

      The QDialog::exec() doc says: "Avoid using this function; instead, use open()."

      Does this mean: avoid modal dialogs for good, always use modeless dialogs?

      Or is there recommended way to run a modal dialog starting with open()?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Joachim-W
      See https://doc.qt.io/qt-5/qdialog.html#modal-prop.

      You can make the dialog be modal with this when it open()s. exec() does that automatically (regardless of setModal()), but also sits there waiting, whereas open() with modal does the modality but does not spin the wait loop (but you can act on signal https://doc.qt.io/qt-5/qdialog.html#finished).

      So long as you don't do anything "naughty", I like a lot of people find it fine to use exec() for the default, normal cases. Purists may advise open(), but exec() works fine for me.

      1 Reply Last reply
      6

      • Login

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