3
私はQTreeViewで表示したいネストされたデータ構造を持っています。ネストされたベクトルのQtカスタムツリーモデル
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;
私はこれらを実装する最良の方法、特にインデックス関数が何であるか分かりません。