Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to disable a window when a new dialog in on top of it?

    General and Desktop
    3
    4
    1746
    Loading More Posts
    • 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.
    • S
      Sriu1 last edited by

      I have mainwindow.ui with some buttons.Finish,Exit,New Dialog etc...
      When "New Dialog" is clicked I'm creating a dialog box with "OK" and "Cancel" buttons.This dialog box appears on top of my mainwindow.I have a requirement that, only after user clicks "Ok" or "Cancel" in the dialog the buttons in the mainwindow should be functional otherwise the buttons in the background should not be functional.Please suggest.

      JonB 1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        This is called window modality. You can set it using modality property.

        (Z(:^

        1 Reply Last reply Reply Quote 4
        • sierdzio
          sierdzio Moderators last edited by

          And here is a bit more info on how it works: https://doc.qt.io/qt-5/qt.html#WindowModality-enum

          (Z(:^

          1 Reply Last reply Reply Quote 3
          • JonB
            JonB @Sriu1 last edited by

            @Sriu1
            You don't even have to bother to set the modality. Assuming you will use QDialog::exec() as your way of displaying the dialog, it does all that you want already:

            exec() ignores the value of this [modal] property and always pops up the dialog as modal.

            1 Reply Last reply Reply Quote 2
            • First post
              Last post