获取文件路径
//打开文件夹中的图片文件
QString inputImagePath = QFileDialog::getOpenFileName(this,
"Please choose an image file",
"",
"Image Files(*.jpg *.png *.bmp *.pgm *.pbm);;All(*.*)");
if (inputImagePath.isEmpty()) {
return;
}
else {
m_s_inputImagePath = inputImagePath;
ui->lineEdit_inputImagePath->setText(m_s_inputImagePath);//将路径显示在lineEdit控件中
}
获取文件夹路径
// 获取文件夹路径
QString filepath = QFileDialog::getExistingDirectory(this,
"Input the image path",
"./");
if (filepath.isEmpty()) {
return;
}
else {
ui->lineEdit_inputImagePath->setText(filepath); //将文件路径显示在lineEdit控件中
}