场景: Qt选择和打开目录,支持中文、空格等
实现:
# 选择目录QString strDir = "D:\\";
QString qslPath = QFileDialog::getExistingDirectory(this, "", strDir);
ui->l_path->setText(qslPath);
# 打开目录QString path = ui->l_path->text();
if (!path.isEmpty()) QDesktopServices::openUrl(QUrl::fromLocalFile(path));
关键: QUrl::fromLocalFile(path)
示例:
标签:中文,文件目录,QT,QString,path,fromLocalFile,打开 From: https://www.cnblogs.com/hely-ljm/p/17991147