Once again i am at a point where i know what i want, but i have no idea how to get there. So i will just tell you what i want an hope you can help me in any way (even if it's just pointing me to some reading material).
My application, Window Detective, monitors windows and logs messages sent to each window. I have a WindowMessage model object to represent each message and a UI which displays each of these messages. I use a tree widget to show each message in the list, where nodes of the tree are parameters of each message. e.g.
+- WM_SETCURSOR
| |
| +- wParam = 0x00020120
| |
| +- lParam = 0x02000001
|
+- WM_MOUSEMOVE
| |
| +- wParam = 0x00000000
| |
| +- lParam = 0x00001234
|
+ ...
+- WM_SETCURSOR
| |
| +- wParam = 0x00020120
| |
| +- lParam = 0x02000001
|
+- WM_MOUSEMOVE
| |
| +- wParam = 0x00000000
| |
| +- lParam = 0x00001234
|
+ ...
To copy to clipboard, switch view to plain text mode
Currently i am just creating and adding tree items when each message is recieved by my application. But now i want to do more advanced things to the UI such as filtering (hiding) certain messages or highlighting them. For that, i need to know stuff about the model object that each top-level tree item represents.
How do i design my model/view to achieve this? I suppose using the QTreeView instead of QTreeWidget would be better, but i am not quite sure how to use it. Despite learning the MVC pattern, i still do not fully understand it.
There are similar cases in my application where i do this sort of thing. For example, the tree that shows a hierarchy of all windows. In that cases, i created a subclass of QTreeWidgetItem which contained a pointer to my Window object. I am not sure if that was a good way to do it, but i cannot use that exact way here because i am not mapping tree items to model objects. Only top-level tree items represent the model object.
I am also thinking about custom rendering and how i could display each object as a list item but which can be expanded to show a tree view of it's parameters (which in the future will contain more than just wParam and lParam). I am just not sure whether i should be subclassing a list view or a tree view for this.
Bookmarks