如何打开文件夹并在Qt中选择文件? [英] How Can I Open A Folder And Have File Selected In Qt?

查看:1823
本文介绍了如何打开文件夹并在Qt中选择文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个filePath m_curProjFile。



我想打开包含该文件的文件夹并选择文件。

(in Windows探索)。



现在我使用:



I have a filePath m_curProjFile.

I want to open the folder containing the file and have the file selected.
(in windows explore).

By Now I used:

QDesktopServices::openUrl(QUrl(QString("file:///")+  QFileInfo(m_curProjFile).absolutePath()));







只能打开文件夹,但我仍然需要找到文件来自长长的名单!



任何提示?



提前感谢!




Only can open the folder but I still have to find the file by eyes from the long list!

any hint?

thanks in advance!

推荐答案

请参阅此Qt论坛主题: http://qt-project.org / forums / viewthread / 18643 [ ^ ] 。



使用系统 QProcess :: execute 命令传递字符串使用 / select 参数启动Windows资源管理器(请参阅 http ://support.microsoft.com/kb/152457/en-us [ ^ ])。



但此解决方案依赖于平台。根据您的要求,您还可以使用 QFileDialog 类来显示文件打开对话框。
See this Qt forum thread: http://qt-project.org/forums/viewthread/18643[^].

Use the system or QProcess::execute command passing a string to start the Windows Explorer with the /select parameter (see http://support.microsoft.com/kb/152457/en-us[^]).

But this solution is platform dependant. Depending on your requirements you might also use the QFileDialog class to show a file open dialog.


这篇关于如何打开文件夹并在Qt中选择文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆