最近有这样一个需求:点击按钮打开对话框选择图片并显示在UI上 getOpenFileName()函数参数填入文件路径,返回选中文件的路径
#include<QFileDialog>
void on_pushButton_clicked()
{
QString curPath
=QDir
::currentPath();
QString str
=QFileDialog
::getOpenFileName(this,"打开文件",curPath
);
qDebug()<<str
;
ui
->label_PicHK
->setPixmap(QPixmap(str
));
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-56271.html