Unsolved QMessageBox::question does not close when I click on X button but works when we have cancel button why so
-
I am doing nothing after yes
answer = QMessageBox::information(this, QObject::tr(Name), QString(QObject::tr("Messages. ")), QMessageBox::Ok);
Noting and I am not getting this behavior when I have QMessageBox::information
-
What OS and Qt version are you running?
-
qt 4.3.3 and centos 6.4
-
It might be a bug, difficult to act on such an old version. try building it manually instead of using the static method:
QPointer<QMessageBox> questionBox=new QMessageBox(QMessageBox::Question,tr("Dialog"),tr(" Do you want to continue?"),QMessageBox::Yes | QMessageBox::No ,this); questionBox->setDefaultButton(QMessageBox::Yes); const int ret = questionBox->exec(); if(questionBox) questionBox->deleteLater(); if(ret==QMessageBox::No){ return false; }
If you are interested in why I use
QPointer
see https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0 -
if I put QMessageCancel then it is working fine why so
answer = QMessageBox::question(parent, QObject::tr("MY NAME"), QString(QObject::tr(" Do you want to continue?"))), QMessageBox::Yes | QMessageBox::No| QMessageBox::Cancel);
-
Looks like it's a Bug in your Qt version. did you try my solution?
If it doesn't work try subclass
QMessageBox
reimplementcloseEvent()
and callreject()
from there -
Just to be sure of qt4.3.3 it works fine on centos 6 and it does not work on rhel 5 linux any idea on KDE settings
-
That is not the correct solution we need to find the proper cause
-
Hi,
Do you realise that you are asking about looking for a solution on a 10 years old version of Qt ? Are you locked to Qt 4.3.3 ?
-
@Qt-Enthusiast said in QMessageBox::question does not close when I click on X button but works when we have cancel button why so:
That is not the correct solution
What do you mean? the messagebox is not closed or you just prefer using the static method rather than building the object?