QMessageBox::question does not close when I click on X button



  • QMessageBox::question does not close when I click on X button but works when we have cancel button why so

    Qt Enthusiast about 21 hours ago
    I have following code

    File dialog.h
    class Dialog : public QDialog
    {
    Q_OBJECT

    public:
    Dialog(QWidget *parent = 0);

    private slots:
    void questionMessage();
    };
    Case1:

    dialog.cpp
    void Dialog::questionMessage()
    {
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, tr("QMessageBox::question()"),
    MESSAGE,
    QMessageBox::Yes | QMessageBox::No );

    if (reply == QMessageBox::Yes)
    qDebug() << "Yes";
    else if (reply == QMessageBox::No)
    qDebug() << "No";
    else
    qDebug() << "Cancel";
    }
    The issue is when I click on X mark at the top right then the QMessagebox does not get closed

    Case2:

    but If I have following code

    void Dialog::questionMessage()
    {
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, tr("QMessageBox::question()"),
    "MESSAGE",
    QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

    if (reply == QMessageBox::Yes)
    qDebug() << "Yes";
    else if (reply == QMessageBox::No)
    qDebug() << "No";
    else
    qDebug() << "Cancel";
    }
    If I put QMessageBox::Cancel then it is working fine . It will be helpful if someone can guide me why I am not able to close QMessageBox with X in Case1

    The issue I am getting only when I have qt.4.3.3 build




Log in to reply
 

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