If your "file system" is a hierarchy (that is, an item can have a parent as well as children), then a tree model is probably the best way to implement this, unless you only show one level at a time. That is, as anda_skoa suggested, your view consists of a simple list of the items at that level of the hierarchy, and you use some other way to move up or down.Can you please send me an example or a code snippet for more understanding?
In the old Windows FileManager program, the right side window displayed only a single level of the file system. To navigate to a lower level, you could double-click a directory entry; to go up a level, you double-clicked the ".." entry. The left side tree view was unnecessary for navigation.
You could derive a class from QStringListModel to represent the items at one level of your hierarchy. The only function you would have to reimplement is the data() method, and in that, the only thing you need to add is a case to handle the Qt::DecorationRole to return the icon for that entry. Everything else can be handled by the QStringListModel::data() implementation.
Google is your friend. There are many examples of how to use QListView, QStringListModel, and Qt::ItemDataRole.
Bookmarks