ID 320395 - Partially checked checkboxes and view items do not appear correctly

Follow

Problem summary:

Checkboxes and view items that are partially checked, as opposed to unchecked or fully checked, do not appear correctly, making it hard or impossible for users to tell those different states apart.

Steps to reproduce:

  1. Execute the following script and look at the appearance of checkboxes and view items:
    • try:    from PySide2 import QtCore, QtGui, QtWidgets    def QVariant(v):        return vexcept:    from PyQt4 import QtCore, QtGui    QtWidgets = QtGui    def QVariant(v):        if v is None:            return QtCore.QVariant()        else:            return QtCore.QVariant(v)class CheckableModel(QtCore.QAbstractTableModel):    def rowCount(self, parentIndex):        return 3    def columnCount(self, parentIndex):        return 1    def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):        if role == QtCore.Qt.DisplayRole:            if orientation == QtCore.Qt.Horizontal and section == 0:                return QVariant('Appearance')            else:                return QVariant(section)        return QVariant(None)    def data(self, modelIndex, role=QtCore.Qt.DisplayRole):        if not modelIndex.isValid():            return        if role == QtCore.Qt.DisplayRole:            if modelIndex.row() == 0:                return QVariant('Unchecked')            elif modelIndex.row() == 1:                return QVariant('Partially Checked')            elif modelIndex.row() == 2:                return QVariant('Checked')        elif role == QtCore.Qt.CheckStateRole:            if modelIndex.row() == 0:                return QVariant(QtCore.Qt.Unchecked)            elif modelIndex.row() == 1:                return QVariant(QtCore.Qt.PartiallyChecked)            elif modelIndex.row() == 2:                return QVariant(QtCore.Qt.Checked)        elif role == QtCore.Qt.SizeHintRole:            if modelIndex.row() == 1:                return QVariant(QtCore.QSize(150, 23))        return QVariant(None)    def flags(self, modelIndex):        if modelIndex.isValid():            return (QtCore.Qt.ItemIsEnabled                    | QtCore.Qt.ItemIsSelectable                    | QtCore.Qt.ItemIsUserCheckable                    | QtCore.Qt.ItemIsTristate)        return QtCore.Qt.NoItemFlagsclass CheckboxAppearanceDialog(QtWidgets.QDialog):    def __init__(self, parent=None):        QtWidgets.QDialog.__init__(self, parent)        self.setWindowTitle('Checkbox Appearance')        self.dataModel = CheckableModel(self)        tableView = QtWidgets.QTableView(self)        tableView.setModel(self.dataModel)        tableView.resizeColumnsToContents()        tableView.resizeRowsToContents()        enabledCheckboxesLayout = QtWidgets.QVBoxLayout()        disabledCheckboxesLayout = QtWidgets.QVBoxLayout()        for text, checkState in (                ('Unchecked', QtCore.Qt.Unchecked),                ('Partially Checked', QtCore.Qt.PartiallyChecked),                ('Checked', QtCore.Qt.Checked)):            checkbox = QtWidgets.QCheckBox(text)            checkbox.setCheckState(checkState)            enabledCheckboxesLayout.addWidget(checkbox)            checkbox = QtWidgets.QCheckBox(text)            checkbox.setCheckState(checkState)            checkbox.setEnabled(False)            disabledCheckboxesLayout.addWidget(checkbox)        checkboxesLayout = QtWidgets.QHBoxLayout()        checkboxesLayout.addLayout(enabledCheckboxesLayout)        checkboxesLayout.addLayout(disabledCheckboxesLayout)        mainLayout = QtWidgets.QVBoxLayout(self)        mainLayout.addWidget(tableView)        mainLayout.addLayout(checkboxesLayout)        dialog = CheckboxAppearanceDialog()dialog.show()

Expected behaviour:

Partially checked checkboxes and view items appear distinctly different from unchecked and checked checkboxes and view items.

Actual behaviour:

Partially checked checkboxes appear with a black checkmark, which is hard to see.

Partially checked view items appear in the same way as fully checked view items, making it impossible to determine the state by looking at the appearance.

Workaround:

No known workaround.

Reproduced versions/platforms:

  • 1.0v1/Linux

Customer version/platform:

Not supplied

    We're sorry to hear that

    Please tell us why