Understanding of TreeItem and TreeModel in QT, [demo]EditableTreeModel

TreeModel is different from QStringListModel, QSqlTableModel, etc. The latter maintains a model instance, and the data (understandable) is directly initialized into the model, while the TreeModel in the demo creates and maintains an instance of a tree-structured TreeItem, in TreeModel::setModelData The parent->insertChildren operation is recursively performed on the root node (TreeItem* rootItem).

===========================================

Note: The TreeItem in the demo is a tree structure. The data stored in each node is consistent with the structure of the item designed in the View and Model, but it is not similar to a QTableWidgetItem object in QTableWidget.

===========================================

demo screenshot


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324534342&siteId=291194637