[Interest] Model for QTreeView
Alex Strickland
sscc at mweb.co.za
Mon Nov 19 16:05:03 CET 2012
On 2012/11/19 04:41 PM, Alex Strickland wrote:
Sorry, I should have shown the header:
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
typedef struct TreeStruct
{
QString name;
QList<QString> leaves;
};
class TreeModel : public QAbstractItemModel
{
public:
TreeModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
private:
QList<TreeStruct> m_treeData;
};
--
Regards
Alex
More information about the Interest
mailing list