Qt World Summit: Submit your Presentation

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 button

    def updateEditorGeometry(self,editor, styleOption, index):

    def setEditorData(self, editor, index):
    print 'setEditorData...', index.data(), editor.class
    The delegate setup is made with
    self.table.setItemDelegateForColumn (2, PlayButtonDelegate(self))
    for row in range(0, self.tableModel.rowCount()):

  • Ah... a wasted afternoon...

    Updating to 4.2 should fix it.

  • 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.


  • Yeah, it's a fixed bug, I did not have the latest PySide. In my defense, it was only released two days after I started.

Log in to reply