[PyKDE] PyQt and trees

Andreas Pakulat apaku at gmx.de
Tue Apr 11 17:06:36 BST 2006


On 11.04.06 17:35:17, Bert Rodiers wrote:
> 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.

With the example application? If you still have a problem with your
"real" application, then there is another problem and you have to build
another example.

If you still have a problem with your example app, I have no idea where
this might come from. It works here with just that change.

Andreas

-- 
Good news.  Ten weeks from Friday will be a pretty good day.




More information about the PyQt mailing list