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. QMessageBox::question does not close when I click on X button
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 830 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      duplicate of https://forum.qt.io/topic/74991/qmessagebox-question-does-not-close-when-i-click-on-x-button-but-works-when-we-have-cancel-button-why-so/6

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      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