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

Checkboxes in a QCombobox

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 5.12.0
    • PySide
    • None
    • Ubuntu 18.04
    • Linux/X11

    Description

      I am trying to create a QComboBox with items that contain checkboxes. I followed the solution posted here and converted the PyQt portions to work with PySide2. If I set the QApplication style to be 'windows', then the checkboxes appear but if I use the 'fusion' style, the checkboxes are hidden.

      The relevant code snippet that creates the QComboBox:

      self._combo = QtWidgets.QComboBox()
          self._combo.setModel(QtGui.QStandardItemModel())        
      
      for i in range(3):
          item = QtGui.QStandardItem(str(i))
          item.setFlags(QtCore.Qt.ItemIsEnabled |
                        QtCore.Qt.ItemIsUserCheckable)
          item.setData(QtCore.Qt.Unchecked, QtCore.Qt.CheckStateRole)
          self._combo.model().setItem(i+1, 0, item

       

      Note: the checkboxes are checked in the 'qcombobox-windows.png' because I had manually checked them prior to taking a screenshot.

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              protonic Matthew Potok
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes