1

I have a QTreeView in my program for picking a directory on Windows OS. It works, however, some users complain that in order to pick My Documents they must expand C:\Users\<user name>\Documents, which is quite slow. They'd prefer to access "Libraries" directly on the root level, like in Windows Explorer on the left (Documents, Music, Pictures...). How can I do this with QTreeView and QFileSystemModel? I'm in Qt 5/C++.

EDIT: Windows explorer contains also other items, which I'd like to include: Network and Favourites.

Andrej Repiský
  • 477
  • 1
  • 6
  • 19

1 Answers1

1

You need to use qstandardpaths

This enum describes the different locations that can be queried using methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, and 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.
GPPK
  • 6,546
  • 4
  • 32
  • 57
  • 1
    That's good, but the question is also how to add this to QTreeView and QFileSystemModel. Also, I'd like to include "Network" and "Favourites" on the root level, where I currently have hard drive letters. I edited my post. – Andrej Repiský Mar 12 '15 at 16:12