I'm trying to add a QLabel
to a QTreeWidgetItem
but Python crashes on the setItemWidget
call.
Any ideas why it crashes?
Here is the code:
from PySide import QtCore, QtGui
view = QtGui.QTreeWidget()
view.show()
newItem = QtGui.QTreeWidgetItem(view)
view.setItemWidget(newItem,0,QtGui.QLabel('abc'))
You need to keep a reference to the label, or give it a parent:
view.setItemWidget(newItem, 0, QtGui.QLabel('abc', view))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With