Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    PySide: Issue using ItemDelegate

    Language Bindings
    2
    4
    4758
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      Nightwish last edited by

      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):
      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))@

      1 Reply Last reply Reply Quote 0
      • N
        Nightwish last edited by

        Ah... a wasted afternoon...

        Updating to 4.2 should fix it.

        1 Reply Last reply Reply Quote 0
        • R
          renato.filho last edited by

          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

          1 Reply Last reply Reply Quote 0
          • N
            Nightwish last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post