![]() ![]() ![]() For simplicity, we will use a list of QVariant objects to store the data for each column in the item. ![]() Since each item in a tree view usually contains several columns of data (a title and a summary in this example), it is natural to store this information in each item. Having this information readily available makes implementing the model easier. However, the root item in the tree structure has no parent item and it is never referenced outside the model.Įach TreeItem contains information about its place in the tree structure it can return its parent item and its row number. Generally, each TreeItem has a parent item, and can have a number of child items. The data is stored internally in the model using TreeItem objects that are linked together in a pointer-based tree structure. Each TreeItem represents an item in a tree view, and contains several columns of data. The data structure that we use to represent the structure of the data takes the form of a tree built from TreeItem objects. In this example, we will implement an internal structure to hold data rather than discuss how to package data from an external source. More generally, models can be used to represent data in the form of a tree structure by allowing each item to act as a parent to a table of child items.īefore attempting to implement a tree model, it is worth considering whether the data is supplied by an external source, or whether it is going to be maintained within the model itself. Simple models represent data as a table of items, and allow views to access this data via an index-based system. Qt's model/view architecture provides a standard way for views to manipulate information in a data source, using an abstract model of the data to simplify and standardize the way it is accessed. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |