One thing you should notice first is that you wanted to represent the data as a tree while you data internally is stored as a list. While implementing something that can map between tree like structure and list like structure on-fly is not impossible, but it will not be easy either.
You have two choices, would you like to store WindowMessage's data into Qt's model or do you want to keep on using the QList?
For first choice, You could use QStandardItemModel, no need to subclass any model classes. Adding new messages would work something like this:
model->invisibleRootItem()->appendRow( messageItem );
messageItem->appendRow( lparamItem );
messageItem->appendRow( wparamItem );
QStandardItem *messageItem = new QStandardItem( messageName );
QStandardItem *lparamItem = new QStandardItem( lParam );
QStandardItem *wparamItem = new QStandardItem( wParam );
model->invisibleRootItem()->appendRow( messageItem );
messageItem->appendRow( lparamItem );
messageItem->appendRow( wparamItem );
To copy to clipboard, switch view to plain text mode
For second choice, you would subclass QAbstractItemModel and use it as an adapter which internally reads the QList and at same time provides an interface (QAbstractItemModel) which the QTreeView can access. In this choice you need to implement the list-tree mapping. You need to also remember to notify the model whenever the QList is being modified, otherwise the QTreeView will not update.
Bookmarks