Styling Checked state in QListWidget?

340 Views Asked by At

In my QListWidget, if i try to add a StyleSheet for the indicator, it appears twice. Like in the image, there is a default checked element and the custom element which cuts the text of the items.

My desired output is to remove the add style to the default checkbox in the listitem or to remove it.

IDK how to overwrite the default checkbox's style

# For every item in the client list widget
for i in range(self.clientListWidget.count()):
    item = self.clientListWidget.item(i)
    # Use the checkbox flag to differentiate between active and inactive clients with a tick mark
    if con.isActiveClient(item.text()):
        item.setCheckState(Qt.Checked)
    else:
        item.setCheckState(Qt.Unchecked)

And in the StyleSheet :

OPTION_CLIENT_MAIN = (
                      "QListWidget"
                      "{"
                      f"border : 3px solid {Palette.PRIMARY_COLOR.value};"
                      f" color : {Palette.SECONDARY_COLOR.value};\n"
                      "  border-radius : 15%;"
                      "outline : 0px;"
                      "padding : 5px;"
                      "}"
                      "QListView::item"
                      "{"
                      "padding : 15px;"
                      "outline : 0px;"
                      "}"
                      "QListView::item:selected"
                      "{"
                      f"border : 3px dashed {Palette.SECONDARY_COLOR.value};"
                      f"background : {Palette.PRIMARY_COLOR.value};"
                      "  border-radius : 15%;"
                      f"color : {Palette.COMMON_COLOR_W.value};"
                      "}"
                      "QListView::item:hover"
                      "{"
                      f"background : {Palette.PRIMARY_COLOR.value};"
                      f"color : {Palette.COMMON_COLOR_W.value};"
                      "}"
                      "QListView::indicator:checked\n"
                      "{\n"
                      f" background-color : {Palette.COMMON_COLOR_G.value};\n"
                      "}\n"
                      "QListView::indicator:unchecked\n"
                      "{\n"
                      f" background-color : {Palette.COMMON_COLOR_R.value};\n"
                      "}\n"
                      )
0

There are 0 best solutions below