Created
September 6, 2012 06:57
-
-
Save Atsushi4/3652304 to your computer and use it in GitHub Desktop.
Use QMessageBox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtGui> | |
class MainWindow : public QDialog | |
{ | |
Q_OBJECT | |
public: | |
MainWindow() | |
{ | |
QPushButton *b; | |
setLayout(new QGridLayout); | |
layout()->addWidget(b = new QPushButton("&show")); | |
connect(b, SIGNAL(clicked()), SLOT(showDialog())); | |
} | |
public slots: | |
void showDialog() | |
{ | |
QString html = "<B>Score</B> : 100<BR>" | |
"<B>Score</B> : 200"; | |
QMessageBox *box = new QMessageBox(QMessageBox::NoIcon | |
, "title" | |
, html | |
, QMessageBox::Ok | QMessageBox::Reset | |
, this); | |
box->setDefaultButton(QMessageBox::Ok); | |
switch (box->exec()) | |
{ | |
case QMessageBox::Ok: | |
qDebug() << "Ok"; break; | |
case QMessageBox::Reset: | |
qDebug() << "Reset"; break; | |
default: | |
qDebug() << "Unknown"; | |
} | |
} | |
}; | |
int main(int argc, char **argv) | |
{ | |
QApplication app(argc, argv); | |
MainWindow w; | |
w.show(); | |
return app.exec(); | |
} | |
#include "messagebox_sample.moc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment