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. QDialog

QDialog

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.5k 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.
  • A Offline
    A Offline
    anandvivek
    wrote on last edited by anandvivek
    #1

    I have QDialog class, inside the class I have one line edit and one push button. My sequence of QDialog opening is, first I will open one main window then, there I will click one pushbutton, it will open one more widget, inside that widget I have search option, if I click search option that time this QDialog will appear. If QDialog is visible I need to disable QMainWindow and Qwidget. That means QDialog should behave like QMessage box. Once I close QDialog after that only I can able to access QMainWindow and Qwidget. Any one can suggest how to do this. Thanks in advance.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      QDialog will do this automatically for you if you use exec() to show it.

      so when search options is clicked() and you say

      Mydialog dia;
      dia.exec(); <<< stays in here and mainwindow should be blocked.

      its called a modal dialog.

      more info here
      http://doc.qt.io/qt-5/qdialog.html#modal-dialogs

      1 Reply Last reply
      1
      • m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by
        #3

        Hi,
        You will need to make the dialog modal setModal(true);.
        -Michael.

        mrjjM A 2 Replies Last reply
        1
        • m.sueM m.sue

          Hi,
          You will need to make the dialog modal setModal(true);.
          -Michael.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @m.sue
          Hi
          The docs says
          exec() ignores the value of this property and always pops up the dialog as modal.

          http://doc.qt.io/qt-5/qdialog.html#modal-prop

          So using exec() should be enough. But always good to know about
          setModal :)

          A 1 Reply Last reply
          1
          • m.sueM m.sue

            Hi,
            You will need to make the dialog modal setModal(true);.
            -Michael.

            A Offline
            A Offline
            anandvivek
            wrote on last edited by
            #5

            @m.sue
            Hi m.Sue,
            I used setModal(true). It is working for me. Thank you very much.

            Regards,
            Vivek

            1 Reply Last reply
            1
            • mrjjM mrjj

              @m.sue
              Hi
              The docs says
              exec() ignores the value of this property and always pops up the dialog as modal.

              http://doc.qt.io/qt-5/qdialog.html#modal-prop

              So using exec() should be enough. But always good to know about
              setModal :)

              A Offline
              A Offline
              anandvivek
              wrote on last edited by
              #6

              @mrjj

              Thanks for your help.

              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