Qt等待对话框结束

来源:互联网 发布:srdcf跟踪算法 编辑:程序博客网 时间:2024/05/22 03:42

 接触Qt一年左右,还算个新手。刚刚一直纠结于如何在等待Qt对话框结束后获得对话框的数据,现在终于搞定了。

ImageSelection *imSelection=new ImageSelection(this);
    if(imSelection->exec()==QDialog::Accepted)
    {
    QString s=imSelection->GetSelectedImage();
    QMessageBox::information(this,"Image",s);

    }

 

其中ImageSelection是QDialog的派生类,要在ImageSelection类中的合适位置写出QDialog::accept()函数。

 

其实这个就和MFC中的CDialog::DoModal()==IDOK是一样的。