■ QMessageBox
示例一:
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
#include <QDebug>
int main(int argc, char *argv[])
{QApplication a(argc, argv);QMessageBox MBox;MBox.setWindowTitle("QMessageBox自定义对话框");MBox.setText("这是一个自定义的对话框");MBox.setIconPixmap(QPixmap("C:\\Users\\xiexuewu\\Desktop\\icon_c.png"));QPushButton *agreeBut = MBox.addButton("同意", QMessageBox::AcceptRole);MBox.exec();if (MBox.clickedButton() == (QAbstractButton*)agreeBut) {qDebug() << "用户点击了同意按钮";}return a.exec();
}
QMessageBox QPushButton{
border: 1px solid black; border-radius: 10px;
}box.setStyleSheet("QLabel{""min-width: 300px;""min-height: 300px; ""font-size:20px;""}""QPushButton {""background-color:#89AFDE;"" border-style: outset;"" border-width: 10px;"" border-radius: 20px;"" border-color: beige;"" font: bold 15px;"" min-width: 15em;"" min-height: 5em;""}""");示例二:
QMessageBox box;
box.setStyleSheet("QLabel{""min-width: 300px;""min-height: 150px; ""font-size: 16px;""color: red;"
"}");
box.setText("这是一个QMessageBox");
box.setWindowTitle("关于");
box.exec();
■
■
■
■
■