文件打开对话框

    QFileDialog dlg(this);
    dlg.setWindowTitle(tr("打开图片"));
    dlg.setWindowIcon(QIcon(":/main/res/图片.png"));
    dlg.setNameFilter(tr("ALL Image Type files(*.png *.jpg *.bmp *.jpeg *.gif *.psd)"));
    QString fileName;
    if(dlg.exec()==QFileDialog::Accepted)
    {
        fileName = dlg.selectedFiles()[0];
    }
    if(fileName.length() <1 ) return ;
    //...后续操作
原文地址:https://www.cnblogs.com/azbane/p/8657356.html