I've got a nested data structure I'd like to display with a QTreeView.
Let's say I've got something like this:
class Image
{
public:
...
std::vector<Filter> filter_;
};
typedef std::vector<Image> Gallery;
typedef std::vector<Gallery> Galleries;
The QTreeView should display the MultiGallery like this:
Gallery1
|_____Image1
|_____Image2
|_____Image3
Gallery2
|_____Image1
| |_____Filter1
| |_____Filter2
|_____Image2
I read the Qt Model View examples, i know I have to derive from QAbstractItemModel to create a treemodel and implement the member functions:
QVariant data(const QModelIndex &index, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int columnCount(const QModelIndex &parent=QModelIndex()) const;
int rowCount(const QModelIndex &parent=QModelIndex()) const;
I just don't know whats the best way to implement these, especially the index function.