PDA

View Full Version : How to get Qmessagebox output?



Gokulnathvc
25th March 2011, 07:52
How to get the button event of the Qmessage box?

If cancel button is clicked, it should reject?? How to reject the process when cancel button is pressed in the message box??

FelixB
25th March 2011, 07:59
please read the documentation of QMessageBox. If you are using static methods, evaluate the return value. if you use exec(), you get the clicked button with "QAbstractButton * clickedButton () const".

the part of "rejecting the process" has nothing to do with qt, that's part of your program logic.

wladek
25th March 2011, 08:02
You can QDialog::exec the message box and test for the result:

if (QMessageBox::Cancel == msgBox.exec)

Hope this is useful.

Regards,
Wladek

Gokulnathvc
25th March 2011, 09:53
1.
if (msgBox.exec==QMessageBox::Cancel )

This works fine.