[Qt-interest] QMessageBox - prototype doubt and also specify default button
Malyushytsky, Alex
alex at wai.com
Fri Sep 11 23:47:42 CEST 2009
>> In the 4th last line from the bottom, its used QMessageBox::Yes | QMessageBox::No.. What does that mean?
This means you will have 2 buttons in the message box: Yes and No
>> ALso, how do i specify the default buton..
You already answered your own question:
>> Ok,StandardButton defaultButton = NoButton )
For example pass QMessageBox::Yes as a fifth parameter
If you don't understand '|' operator I highly recommend reading C/C++ book before going any further.
Also such kind of question better not to ask. Don't afraid to run tests when learning.
If you answer them yourself you will remember answers for life.
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Abhijeet Rastogi
Sent: Friday, September 11, 2009 1:29 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QMessageBox - prototype doubt and also specify default button
#include<QtGui>
int main (int argc, char* argv[])
{
QApplication app(argc, argv);
QTextStream cout(stdout, QIODevice::WriteOnly);
// Declarations of variables
int answer = 0;
do {
// local variables to the loop:
int factArg = 0;
int fact(1);
factArg = QInputDialog::getInteger(0, "Factorial Calculator",
"Factorial of:", 1);
cout << "User entered: " << factArg << endl;
int i=2;
while (i <= factArg) {
fact = fact * i;
++i;
}
QString response = QString("The factorial of %1 is %2.\n%3")
.arg(factArg).arg(fact)
.arg("Do you want to compute another factorial?");
answer = QMessageBox::question(0, "Play again?", response,
QMessageBox::Yes | QMessageBox::No);
} while (answer == QMessageBox::Yes);
return EXIT_SUCCESS;
}
In the 4th last line from the bottom, its used QMessageBox::Yes | QMessageBox::No.. What does that mean?
Its prototype is:
StandardButton QMessageBox::question ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok,StandardButton defaultButton = NoButton ) [static]
ALso, how do i specify the default buton.. Pls make me understand.. I know its very basic funtion but pls do help.
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list