/ MVC

Treeviews in PyQt with QAbstractItemModel

For the new feature of SynCE-KPM I am working on at the moment, I want to emulate the look and feel of the windows standard program regedit.exe. This means showing the user a QTreeView showing the hierarchy of the keys and a QListView on the right showing all values within the selected key.

While the other day I have been working (and finished) on the librapi2 stuff, in particular the python bindings, to facilitate a registry editor, for some days I have been looking at this whole QTreeView stuff. I have to say that I really do appreciate the idea behind MVC, but I have to say that to use this in a nice way in PyQt is really difficult. After some days I am now at least able to create a nice QTreeView based on a model that represents the registry. Currently, everything is still hardcoded, but at least I can see a structure now (the QListView with values will come much later :) ).

Next step is to see if I can connect the model to the actual contents of the registry on the device in a dynamic way. The problem is that I need to fetch new data from the registry only when it is needed. One simple approach is to first read the complete registry into the model and then show this to the user. However, I don’t think users will like it if there is a 5 minute delay showing “Fetching data” when going to the registry editor before they can actually use the registry editor. This means I will have to fetch data in some asynchronous way. Fortunately, I already have some ideas about this. For some reason I think this fetching part is again the easy component….. Don’t want to think about all the mess that is involved to show this in a nice way to the end-user.

For the moment just happy that at least the very basics of the left-hand side of the future screen (i.e. the hierarchy of the keys) needed to display actual data are there. Onwards to new challenges with PyQt and its MVC :)

Guido Diepen

Guido Diepen

Senior Data Scientist at T-Mobile NL | Fascinated with new technologies and tools | Trying to automate the boring bits of life | Love to travel

Read More