QDialog类是所有对话框窗口类的基类。
模态对话框的创建:
QDialog dialog(this); //指明类对话框的父类,则不需要delete来释放该对象
dialog.exec();
非模态对话框的创建:
QDialog * dialog=new QDialog(this);
dialog->show();
另:使用new出来并show的非模态对话框也可以变成模态对话框。如下:
QDialog *dialog=new QDialog(this);
dialog->setModal(true); //或者使用dialog->setWindowModal(Qt::ApplicationModal);
dialog->show();