PySide: Issue using ItemDelegate
-
I'm doing a simple app while learning Qt, and I've hit a brick wall with QItemDelegate. I'm using a button on a column to do something with it at a later point, but when setEditorData is called, the editor parameter is a QWidget, not the QPushButton I've created. Every single example I've seen has the call being made with the proper widget, so I'm stumped.
I'd like to change the text on the button, but if i cache the button somewhere i get
@RuntimeError: Internal C++ object already deleted.@The delegate is
@class PlayButtonDelegate(QtGui.QItemDelegate):def init(self, parent=None, *args):
QtGui.QItemDelegate.init(self, parent)def createEditor(self, parent, styleOption, index):
button=QtGui.QPushButton(QtGui.QPixmap('Play-Normal-icon.png'), index.data(), parent)
return buttondef updateEditorGeometry(self,editor, styleOption, index):
editor.setGeometry(styleOption.rect);def setEditorData(self, editor, index):
print 'setEditorData...', index.data(), editor.class
editor.setText(index.data())@
The delegate setup is made with
@
self.table.setItemDelegateForColumn (2, PlayButtonDelegate(self))
for row in range(0, self.tableModel.rowCount()):
self.table.openPersistentEditor(self.tableModel.createIndex(row,2))@ -
I created a small example here and apparently this work fine with 0.4.2.
Could you test and if the bug persist on 0.4.2 use our "bugzilla":http://bugs.openbossa.org/ to report this, with a full example attached.
Thanks