以下为笔记:
1,3/4 msgbox = new QMessageBox(tr("接口板登记"),tr("接口板登记中..."),
QMessageBox::Information,
QMessageBox::Ok | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape,
QMessageBox::NoButton );
QMessageBox::Information,
QMessageBox::Ok | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape,
QMessageBox::NoButton );
2,2/4 QMessageBox::QMessageBox ( Icon icon, const QString & title, const QString & text, StandardButtons buttons = NoButton, QWidget * parent = 0, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint)
enum | ButtonRole { InvalidRole, AcceptRole, RejectRole, DestructiveRole, ..., ResetRole } |
enum | Icon { NoIcon, Question, Information, Warning, Critical } |
enum | StandardButton { Ok, Open, Save, Cancel, ..., ButtonMask } |
for eg:
QMessageBox *msgbox1 = new QMessageBox(QMessageBox::Information,
tr("接口板登记"),
tr("接口板登记中..."),
QMessageBox::NoButton,0);
msgbox1->exec();
tr("接口板登记中..."),
QMessageBox::NoButton,0);
msgbox1->exec();
执行结果:
问题
1,qt编译错误cannot open output file fileTest: Permission denied:一般是应用程序没有完全退出。如果不能在任务管理器中kill,那么可以强制关闭qt。
2,qmessagebox.resize()函数并不起作用。
以下为转载:原文链接:找不到了。。。sigh
QMessageBox box;
box.setWindowTitle(tr("警告"));box.setIcon(QMessageBox::Warning);
box.setText(curFile+tr("尚未保存,是否保存?"));
box.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
if(box.exec()==QMessageBox::Yes) do_file_Save();
QMessageBox::critical(NULL,"critical","Content",
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
//第二种
QMessageBox message(QMessageBox::NoIcon,"Show Qt","Do you want to show Qt dialog?", QMessageBox::Yes | QMessageBox::No, NULL);
if(message.exec() == QMessageBox::Yes)
{
QMessageBox::aboutQt(NULL,"About Qt");
}
//第三中
QMessageBox::StandardButton rb = QMessageBox::question(NULL,"Show Qt","Do you want to show Qt dialog?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(rb == QMessageBox::Yes)
{
QMessageBox::aboutQt(NULL,"About Qt");
}