[Qt-interest] QMessageBox - prototype doubt and also specify default button

Abhijeet Rastogi abhijeet.1989 at gmail.com
Fri Sep 11 22:29:18 CEST 2009


#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.html#StandardButton-enum> QMessageBox::question
( QWidget <qwidget.html> * *parent*, const QString <qstring.html> & *title*,
const QString <qstring.html> & *text*,
StandardButtons<qmessagebox.html#StandardButton-enum>
 *buttons* = Ok,StandardButton <qmessagebox.html#StandardButton-enum> *
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090912/4309e03f/attachment.html 


More information about the Qt-interest-old mailing list