【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)

示例:

posted @   hely_ljm  阅读(618)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示