[PyKDE] PyQt and trees

Bert Rodiers bert.rodiers at gmail.com
Tue Apr 11 16:35:17 BST 2006


On 4/10/06, Andreas Pakulat <apaku at gmx.de> wrote:

> This one's easy: The model instance is local to the test function and
> thus gets garbage collected when test ends. So the Tree doesn't have a
> model to work with at that point. Changing test to
>
> def test(self):
>   self.model = TreeModel()
>   self.treeView.setModel(self.model)
>
> makes the app work. Or you could make the TreeModel a child of the
> treeView or some other QObject derived instance that you have. It's just
> important that at least 1 reference to the created object is available
> after the function is done so the object is not gc'ed.


Hmm, I hadn't tested your solution yet. Now I did, however I still
have the same problem.

Regards,
Bert




More information about the PyQt mailing list