QTreeView で表示したいネストされたデータ構造があります。
私がこのようなものを持っているとしましょう:
class Image
{
public:
...
std::vector<Filter> filter_;
};
typedef std::vector<Image> Gallery;
typedef std::vector<Gallery> Galleries;
QTreeView は、次のように MultiGallery を表示する必要があります。
Gallery1
|_____Image1
|_____Image2
|_____Image3
Gallery2
|_____Image1
| |_____Filter1
| |_____Filter2
|_____Image2
Qt モデル ビューの例を読みました。QAbstractItemModel から派生してツリーモデルを作成し、メンバー関数を実装する必要があることはわかっています。
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;
これら、特にインデックス関数を実装する最良の方法がわかりません。