Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Not visible checkBox in ComboBox



  • Hi!
    I use qDarkStyle.
    If I do this, then not visible checkBox in ComboBox. Maybe need set styleSheet for comboBox?

    comboBox = QComboBox()
                comboBox.addItems(checkableParameter.arrayParameters)
                # self.arrayWidgets.append(comboBox)
                modelItems = QStandardItemModel()
                i = 0
                for parameter in checkableParameter.arrayParameters:
                    # print(parameter)
                    item = QStandardItem()
                    item.setText(parameter)
                    item.setCheckable(True)
                    item.setCheckState(0)
                    modelItems.setItem(i, item)
                    i += 1
                comboBox.setModel(modelItems)
    


  • It is work

    class CheckBoxDelegate(QItemDelegate):
        def __init__(self, parent=None):
            super(CheckBoxDelegate, self).__init__(parent)
    
        def createEditor(parent, op, idx):
            self.editor = QCheckBox(parent)
    
                comboBox = QComboBox()
                comboBox.addItems(checkableParameter.arrayParameters)
                delegate = CheckBoxDelegate()
                comboBox.setItemDelegate(delegate)
                # self.arrayWidgets.append(comboBox)
                modelItems = QStandardItemModel()
                i = 0
                for parameter in checkableParameter.arrayParameters:
                    # print(parameter)
                    item = QStandardItem()
                    item.setText(parameter)
                    item.setCheckable(True)
    
                    item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
                    item.setData(QtCore.Qt.Unchecked | QtCore.Qt.CheckStateRole)
                    item.setCheckState(2)
                    modelItems.setItem(i, item)
                    i += 1
                comboBox.setModel(modelItems)
    

Log in to reply