代码如下:
QFileDialog* openFilePath = new QFileDialog( this, " select the dircrtory", "file");
openFilePath->setFileMode( QFileDialog::Directory);
if ( openFilePath->exec() == QDialog::Accepted )
{
QDir dir = openFilePath->directory();
QString str = dir.currentPath();
qDebug()<<str;
}
假设我选择了 C:/A/B B这个文件夹 最后输出的只是C:/A
------解决思路----------------------
QFileDialog *filedialog = new QFileDialog();
QString str = filedialog->getExistingDirectory(this,tr("Save"),tr("."));