# PoJsonTreeModel **Repository Path**: potato_code/po-json-tree-model ## Basic Information - **Project Name**: PoJsonTreeModel - **Description**: Qt开发基于QJsonModel基础上完成通过加载json数据或者json文件,然后注入到树形数据模型PoJsonTreeModel中进行数据展示 使用工具Qt creator - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-06 - **Last Updated**: 2025-01-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PoJsonTreeModel #### 介绍 Qt 开发基于QJsonModel上完成 通过加载json数据或者json文件,注入到树形数据模型PoJsonTreeModel中 再使用QWidget的QTreeView 进行数据展示 使用工具Qt creator #### 软件架构 Qt creator Qt 5.15 #### 安装教程 git clone https://gitee.com/potato_code/po-json-tree-model.git #### 使用说明 path_to_example_json_file.json ``` { "name":"123", "children":[ { "name":"wangwu", "sex": "man", "children":[ {"name":"wangwu","age":13}, {"name":"lisi"} ] }, { "name":"lisi", "children":[ {"name":"wangwu"}, {"name":"lisi"} ] } ] } ``` ``` #include #include #include #include #include #include "pojsontablemodel.h" int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); PoJsonTreeModel * model = new PoJsonTreeModel; model->load(":/path_to_example_json_file.json"); QTreeView *view = new QTreeView(); view->setModel(model); view->show(); // QQmlApplicationEngine engine; // engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); // if (engine.rootObjects().isEmpty()) // return -1; return app.exec(); } ``` ![Image text](doc/screen.png)