[PyQt] inheriting QTreeWidgetItem Question
dizou
di_zou at yahoo.com
Thu Nov 12 18:58:25 GMT 2009
Phil Thompson-5 wrote:
>
> 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
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
So I have this now:
class A(QTreeWidgetItem):
def __init__(self, parent):
QTreeWidgetItem.__init__(parent)
class B(QTreeWidget):
#stuff
def f():
tree = A(self)
tree.setFlags(...)
tree.setIcon(...)
tree.setText(...)
When function f() is called, I get this error:
tree.setFlags(...)
RuntimeError: underlying C/C++ object has been deleted
--
View this message in context: http://old.nabble.com/inheriting-QTreeWidgetItem-Question-tp26324003p26324404.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list