QT 中的模态和非模态对话框

 

void MainWindow::on_pushButton_clicked()

{

    //模态

    QDialog dlg(this);

    dlg.resize(100,100);

    dlg.exec();

 

    qDebug()<<"hello world";

 

 

    //非模态

    QDialog *dlg2=new QDialog(this);

    dlg2->resize(200,200);

    //释放内存, 当点击关闭的时候

    dlg2->setAttribute(Qt::WA_DeleteOnClose);

    dlg2->show();

 

    qDebug()<<"hello world2";

 

}

 

 

/// 消息对话框

QMessageBox::question(this,"","",QMessageBox::Save|QMessageBox::Cancel);
原文地址:https://www.cnblogs.com/bruce1992/p/14264783.html