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. How to disable a window when a new dialog in on top of it?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 3.3k 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.
  • S Offline
    S Offline
    Sriu1
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      1 Reply Last reply
      4
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        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
        3
        • S Sriu1

          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.

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

          @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
          2

          • Login

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