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

Checkboxes in a QCombobox

XMLWordPrintable

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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes