Details
Description
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
Attachments
Issue Links
- is duplicated by
-
QTBUG-130896 QComboBox: checkable QStandardItem text overlaps checkbox on Windows
-
- Closed
-
-
PYSIDE-2906 In Qt 6.7.x+ with the windows11 style, checkboxes and items in a custom QComboBox overlap, breaking the UI. This issue is absent in Qt 6.6.3 and earlier, suggesting a regression related to the style changes introduced in newer Qt versions.
-
- Closed
-
For Gerrit Dashboard: PYSIDE-2897 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
599325,4 | QWindows11Style: Add checkbox offset to ItemViewItemText | dev | qt/qtbase | Status: MERGED | +2 | 0 |
599676,2 | QWindows11Style: Add checkbox offset to ItemViewItemText | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |