[Python] How to get rid of the extra corner on the right bottom of QComboBox with PyQt?

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I am working on a combobox with PyQt. I am expecting to have round corners on the dropdown. Here is what it looks like now:

    [​IMG]

    As it shows, there is a white corner with 0 radius on the bottom right. What is confusing is that when I place the window on top of a black background, the extra would "go away" or maybe it is just black:

    [​IMG]

    I tried it with other colors and it is hard to tell what color that corner would turn into:

    [​IMG]

    Does anyone know what might be the cause of that extra corner, or how to remove it?

    Here is my code:

    self.label = QLabel("smething")

    self.combobox = QComboBox()
    self.combobox.addItems(["1","2","3","4"])

    vbox = QVBoxLayout(self)
    vbox.addWidget(self.label)
    vbox.addWidget(self.combobox)

    widget = QWidget(self)
    widget.setLayout(vbox)

    self.resize(200,100)
    widget.resize(200,100)

    self.combobox.view().window().setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
    self.combobox.view().window().setAttribute(Qt.WA_TranslucentBackground)

    self.setStyleSheet("""
    QComboBox {
    background-color: black;
    color: #00ff00;
    selection-background-color: transparent;
    border: 1.5px solid #00ff00; /* Border color and thickness */
    border-radius: 5px; /* Rounded corners of the button */
    padding: 5px;
    }
    QComboBox editable {
    background-color : yellow;
    }
    QComboBox QAbstractItemView {
    color: #00ff00; /* Text color of the drop-down items */
    background-color: red; /* Optional: Set background color of the drop-down list */
    border: 1.5px solid #00ff00; /* Border of the drop-down list */
    border-radius: 10px; /* Rounded corners for the drop-down list */
    selection-background-color: #00ff00;
    selection-color: red;
    padding: 5px;
    }
    """)

    Continue reading...

Compartilhe esta Página