[PyKDE] PyQt and trees

Bert Rodiers bert.rodiers at gmail.com
Sun Apr 9 22:27:09 BST 2006


Hello everybody,

I have some problems with trees. I tried several different
alternatives: doing most myself with treemodels and treeitems and
doing things with QTreeWidgets and QTreeWidgetItems; and in both cases
I ran into certain problems.

First I describe what I did and what didn't work in the case of the
model based solution. As a result of a certain action the tree has to
be filled in. At that moment I created the model and changed the model
to the new model:
		model = TreeModel(tree)
		self.networkTree.setModel(model)
If I ran this program, the tree wasn't filled in. However when I
debugged it it was filled in. It was enough to put a breakpoint in the
__init__ function of TreeModel to have the tree being filled in. Has
somebody else also had this problem? And what to do about it? I tried
running self.networkTree.update() or self.networkTree.repaint(), but
this didn't help.

My second try was with QTreeWidgets, but than also the tree didn't
refresh (this time even not when I was debugging... ;-) )
I expected that the tree updates when I insert a widget, for example with:
		self.networkTree.insertTopLevelItem(0, treeRoot)

Another problem which I have specifically with trees is that I don't
get their signals, for other widgets it works. An example is:
QtCore.QObject.connect(self.networkTree,
QtCore.SIGNAL("itemSelectionChanged()"),
self.newNetworkSelectionCallBack) for QTreeWidgets.

Can somebody have any clues about what could be wrong?
By the way, I'm using using PyQt4-gpl-snapshot-20060407 and qt4.1.2

Thanks,
Bert




More information about the PyQt mailing list