[PyQt] inheriting QTreeWidgetItem Question
Phil Thompson
phil at riverbankcomputing.com
Thu Nov 12 18:41:44 GMT 2009
On Thu, 12 Nov 2009 10:36:34 -0800 (PST), dizou <di_zou at yahoo.com> wrote:
> I am trying to get a class i wrote that inherits QTreeWidgetItem to
display
> on the QTreeWidget. If I used just the normal QTreeWidgetItem I would
have
> code like this:
>
> tree = QTreeWidgetItem(self)
> tree.setFlags(...)
> tree.setIcon(...)
> tree.setText(...)
>
> However I have a class that inherits the QTreeWidgetItem class:
>
> class A(QTreeWidgetItem):
> def __init__(self):
> QTreeWidgetItem.__init__(self)
>
> Then when I do this:
>
> tree = A(self)
> tree.setFlags(...)
> tree.setIcon(...)
> tree.setText(...)
>
> nothing is displayed in the QTreeWidget. What do I have to do to get the
> items to be displayed?
You aren't passing a parent to QTreeWidgetItem.__init__() so its probably
being garbage collected.
Phil
More information about the PyQt
mailing list