Ai
15 Star 136 Fork 128

百里杨/C++ demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
TreeModel.h 879 Bytes
一键复制 编辑 原始数据 按行查看 历史
百里杨 提交于 2020-05-02 17:04 +08:00 . 新增QTreeView+自定义model实现代码
#ifndef TREEMODEL_H
#define TREEMODEL_H
#include <QAbstractItemModel>
class TreeItem;
class TreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit TreeModel(const QStringList& headers, QObject *parent = nullptr);
~TreeModel() override;
TreeItem *root();
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
private:
TreeItem *itemFromIndex(const QModelIndex &index) const;
private:
QStringList _headers;
TreeItem* _rootItem;
};
#endif // TREEMODEL_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/bailiyang/cdemo.git
git@gitee.com:bailiyang/cdemo.git
bailiyang
cdemo
C++ demo
master

搜索帮助