Why show() makes message box modal?



  • 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}



  • 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);
    }
    @



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



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



  • 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"



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.