QMessageBox::information(NULL, "Title", "Content", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
StandardButton QMessageBox::information(QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton) [static] |
QMessageBox::information(NULL, "Title", "Content"); |
QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No); |
QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No| QMessageBox::Abort); |
enum StandardButton { // keep this in sync with QDialogButtonBox::StandardButton NoButton = 0x00000000, Ok = 0x00000400, Save = 0x00000800, SaveAll = 0x00001000, Open = 0x00002000, Yes = 0x00004000, YesToAll = 0x00008000, No = 0x00010000, NoToAll = 0x00020000, Abort = 0x00040000, Retry = 0x00080000, Ignore = 0x00100000, Close = 0x00200000, Cancel = 0x00400000, Discard = 0x00800000, Help = 0x01000000, Apply = 0x02000000, Reset = 0x04000000, RestoreDefaults = 0x08000000, FirstButton = Ok, // internal LastButton = RestoreDefaults, // internal YesAll = YesToAll, // obsolete NoAll = NoToAll, // obsolete Default = 0x00000100, // obsolete Escape = 0x00000200, // obsolete FlagMask = 0x00000300, // obsolete ButtonMask = ~FlagMask // obsolete }; |
QMessageBox:: StandardButton result= QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No); switch (result) { case QMessageBox::Yes: qDebug()<<"Yes"; break; case QMessageBox::No: qDebug()<<"NO"; break; default: break; } |
QMessageBox::critical(NULL, "critical", "Content", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
QMessageBox::warning(NULL, "warning", "Content", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
QMessageBox::question(NULL, "question", "Content", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
QMessageBox::about(NULL, "About", "by hjwblog.com"); |
void MainWindow:n_pushButton_clicked() { QMessageBox messageBox; messageBox.show(); } |
void MainWindow:n_pushButton_clicked() { static QMessageBox messageBox; messageBox.show(); } |
void MainWindow:n_pushButton_clicked() { QMessageBox *messageBox=new QMessageBox; messageBox->show(); } |
void MainWindow:n_pushButton_clicked() { QMessageBox messageBox(QMessageBox::NoIcon, "退出", "你确定要退出吗?", QMessageBox::Yes | QMessageBox::No, NULL); ; int result=messageBox.exec(); switch (result) { case QMessageBox::Yes: qDebug()<<"Yes"; close(); break; case QMessageBox::No: qDebug()<<"NO"; break; default: break; } } |
欢迎光临 纳速健身 (https://nasue.com/) | Powered by Discuz! X3.4 |