[PyKDE] More Newbie TreeView foolishness

johannes_graumann at web.de johannes_graumann at web.de
Fri Oct 6 09:10:08 BST 2006

> I can't remember the code that pyuic4 generates off the top of my head,
> but is the tree actually being instantiated?
Yes (you can e.g. add items right away of you use QTreeWidget rather than QTreeView ...

> A definate problem is that the model is being garbage collected. Either do
> "self.model" instead of "model" or (my preference) make the tree the
> parent object of "model".
Both works. I adopt your preference and solve this issue by doing:


import glob
from PyQt4 import QtGui, QtCore, uic
import sys

class RepositoryTree:
  def __init__(self,Tree):
    self = Tree
    self.model = QtGui.QDirModel()

if __name__=="__main__":
  UserInterface = uic.loadUi("ElNotes_GUI.ui")
  RepositoryTree = RepositoryTree(UserInterface.RepositoryTree)
  Application.connect(Application, QtCore.SIGNAL("lastWindowClosed()"),Application, QtCore.SLOT("quit()"))

Thanks for your help!

Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!

More information about the PyQt mailing list