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

QCombobox Checkstates collide with text on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • 6.8.1
    • 6.8.0.1
    • PySide
    • None
    • Windows
    • 877b29a78 (dev), 71cba1359 (6.8)

      When creating an QStandardItemModel with checkable Items the text of the items collides with the checkboxes if the model is placed into a QComboBox.

      Example Code:

      from PySide6.QtWidgets import QApplication, QComboBox, QVBoxLayout,QWidget
      from PySide6.QtGui import QStandardItemModel, QStandardItem
      from PySide6.QtCore import Qt
      
      if __name__ == "__main__":
          app = QApplication([])
      
          model = QStandardItemModel()
          items = ['Option 1', 'Option 2', 'Option 3', 'Option 4']
          for row, item_text in enumerate(items):
              item = QStandardItem(item_text)
              item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)  # Enable the checkbox
              item.setData(Qt.Unchecked, Qt.CheckStateRole)  # Default to unchecked
              model.setItem(row, 0, item)
          
          container = QWidget()
          layout = QVBoxLayout()
          container.setLayout(layout)
      
          combo = QComboBox()
          combo.setModel(model)
          layout.addWidget(combo)
      
          container.show()
          app.exec()

      result:

      this is a windows specific problem

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

            crmaurei Cristian Maureira-Fredes
            cmellueh Christoph Mellüh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes