对话框,QMessageBox

模态对话框,关闭模态对话框,才可以操作主窗口

QDialog *dlg = new QDialog();
    dlg->resize(400,300);
    dlg->setWindowTitle("对话框");
    dlg->exec();

非模态对话框,可以操作主窗口

	QDialog *dlg = new QDialog();
    dlg->resize(400,300);
    dlg->setWindowTitle("对话框");
    dlg->show();

//最后的显示方式不同

特点 exc键关闭对话框

要记得将Qdialog放在类的属性里,这样类释放时,也会将QDialog释放

消息对话框

StandardButton QMessageBox::critical(QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton) [static]

QMessageBox::critical(this,"critical", "错误提示",QMessageBox::Cancel);

//最后一个参数设置默认的按钮
QMessageBox::information(this, “information”, “信息提示”,QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Cancel);

QMessageBox::about(this,"about","关于");

QMessageBox::question(this,"question","问题");

QMessageBox::warning(this,"warning","警告");

特点:每个对话框显示的图片不同

猜你喜欢

转载自blog.csdn.net/weixin_43340991/article/details/89462309