Python/pyside Using A Custom Widget In A Qtreewidget
Solution 1:
There are 2 options you might want to consider:
You can create your own class which is a subclass of a
QTreeWidget
. This is straightforward as you simply just use the method you have as is and put it inside the class. But this does not really change a lot, except for the fact that it will look more "natural" when calling this on your custom widget.The other method, which is what you are most probably referencing when talking about the documentation is the Model/View architecture.
In that case, you will have to use the QTreeView
and create your own QTreeModel
. Here, the view has absolutely no idea what the data is, and the model is responsible for providing all the data, and notifying the view when it's ready to display. So you have to make that object and emit a signal when the data is ready/changes, so that the view is updated.
For an idea of how you can implement something similar you can have a look at the examples provided with PySide. Most probably you have them installed, look in site-packages/PySide/examples/itemviews/simpletreemodel
.
Also, consider looking into the indexWidget method so that you can add your QEditLine
where needed and call the parent for the default.
Post a Comment for "Python/pyside Using A Custom Widget In A Qtreewidget"