在QTreeView和QFileSystemModel中显示“Windows库”

时间:2015-03-12 09:53:01

标签: qt qtreeview qfilesystemmodel

我的程序中有一个用于在Windows操作系统上选择目录的QTreeView。但是,有些用户抱怨说,为了选择我的文档,他们必须扩展C:\ Users \< user name> \ Documents,这很慢。他们更喜欢直接在根级别访问“库”,例如在左侧的Windows资源管理器中(文档,音乐,图片......)。如何使用QTreeView和QFileSystemModel执行此操作?我在Qt 5 / C ++。

编辑:Windows资源管理器还包含其他项目,我想包括这些项目:网络和收藏夹。

1 个答案:

答案 0 :(得分:1)

您需要使用qstandardpaths

此枚举描述了可以使用QStandardPaths :: writableLocation,QStandardPaths :: standardLocations和QStandardPaths :: displayName等方法查询的不同位置。

QStandardPaths::MusicLocation   4   Returns the directory containing the user's music or other audio files. This is a generic value. If no directory specific for music files exists, a sensible fallback for storing user documents is returned.

QStandardPaths::MoviesLocation  5   Returns the directory containing the user's movies and videos. This is a generic value. If no directory specific for movie files exists, a sensible fallback for storing user documents is returned.