Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-73

QTreeWidget.setItemWidget does not work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.9
    • 1.1.0
    • PySide
    • f93da21b3286db1bf693c26df47a538e581ff908

    Description

      The method setItemWidget of a QTreeWidget is used to set a widget for a given column for a given item.

      setItemWidget has been confirmed to work with PyQt 4.9.1, however, it does not show anything when using either PySide 1.1.0 or PySide 1.1.1

      The following test program was used. It will create a small window with single item. The second column of the item will have a QPushButton. Comment the line "from PyQt4 import QtGui" and uncomment the line "from PySide import QtGui" to use PySide. No button will be shown in that case.

      import sys
      
      # If using PyQt4, a push button will be shown on column 1 of the tree widget
      from PyQt4 import QtGui
      
      # If using PySide, no button will be shown on column 1 of the tree widget
      #from PySide import QtGui
      
      app = QtGui.QApplication(sys.argv)
      
      treeWidget = QtGui.QTreeWidget()
      treeWidget.setColumnCount(2)
      
      item = QtGui.QTreeWidgetItem(['text of column 0', ''])
      treeWidget.insertTopLevelItem(0, item)
      treeWidget.setItemWidget(item, 1, QtGui.QPushButton('Push button on column 1'))
      
        
      treeWidget.show()
      
      app.exec_()
      sys.exit()
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            julian_herrera Julian Alberto Herrera
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes