QFileSystemModel root path
I'm using QFileSystemModel with Tree View model to show file system structure.
But I'd like to show only it only from users directory (QDir::homePath()), not entire file structure (all drives and onwards).
In docs I've found only QFileSystemModel::setRootPath() method, but it only install watcher ( which takes ages to load). I've also noticed that mentioned method returns QModelIndex, but I don't know what to do with it.
Note: I'm very new to models.
As you already said, QFileSystemModel::setRootPath() only defines the path where the watcher will be installed, not the root of the file system hierarchy. What you want to do should be achieved by configuring the View to only show a sub-set of the Model, not by trying to modify the Model itself. Give QTreeView::setRootIndex() a try!
You can use QFileSystemModel::index(const QString &path) to get the QModelIndex of the QDir::homePath() ;-)
It works :) .
As you said, I was searching in the wrong place.
Marked as solved.