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. Why show() makes message box modal?
Forum Updated to NodeBB v4.3 + New Features

Why show() makes message box modal?

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

    The "documentation ":http://qt-project.org/doc/qt-5.0/qtwidgets/qmessagebox-members.html of message box says exec() makes it blocking and show() makes it as good as setVisible(true)
    But I cant figure out why my follwoing code makes it blocking

    {code}
    QMessageBox* msg= new QMessageBox(this);

    msg->setText("Hurrah!!!");
    
     message->show();
    

    {code}

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Hi, the QDialog class has a property called modal, which has been set to true in the constructor of QMessageBox. That's all.

      @
      void QDialog::setModal(bool modal)
      {
      setAttribute(Qt::WA_ShowModal, modal);
      }
      @

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Immii
        wrote on last edited by
        #3

        that indicates unless you dont explicitly set that property off, show() will make is blocking.

        Then document of show() should have different message than QWidget::show()

        This document must be confusing others too.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          Hi,
          The docs are very clear. Modal is set to true as default, so show and exec will have the "same modality". Set the modal to false and your ok. Sorry, docs are very clear to me.

          Greetz, Jeroen

          1 Reply Last reply
          0
          • I Offline
            I Offline
            Immii
            wrote on last edited by
            #5

            can you please point me to that section of doc of QMessageBox. I could not find any thing which says what you are saying?

            If you go to show() doc of QMessageBox it does not says that because it goes to QWidget::show()

            and in rest of the QMessageBox I could not find that thing which says"Modal is set to true as default"

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dbzhang800
              wrote on last edited by
              #6

              Hi, the first paragraph of QMessageBox's documentation says that:

              bq. The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer.

              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