【QT】选择和打开中文路径文件目录
场景: 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)
示例:



浙公网安备 33010602011771号