0

So I have a QComboBox and I want to add some padding between the top bar and the items. Here is the code:

from PyQt6.QtWidgets import QComboBox

class DropDown(QComboBox):
    def __init__(self , parent):
        super().__init__(parent)

        items = ["Science" , "Arts" , "Computer"]

        self.setStyleSheet("""
            QComboBox{
                background-color: #4C566A;
                outline: none;
                border: none;
                height: 50px;
                border-radius: 10px;
                color: #D8DEE9;
                font-family: Comfortaa;
                padding-left: 20px
            }

            QComboBox::down-arrow{
                image: url(frontend/assets/svgs/downarrow.svg)
            }

            QComboBox::drop-down{
                subcontrol-origin: padding;
                subcontrol-position: top right;
                width: 30px;
                padding-right: 10px;
                border-left-width: 1px;
                border-top-right-radius: 3px;
                border-bottom-right-radius: 3px;
            }

            QComboBox QAbstractItemView {
                background-color: #4C566A;     
            }
        """)

        self.addItems(items)

But it seems like I didn't get one :(

Things I have tried:

  • Add padding-top to QComboBox QAbstractItemView
  • Add padding-top to QComboBox QAbstractItemView and setting the background-color to transparent.
  • Add margin-top
BladeOfLightX
  • 504
  • 4
  • 17
  • What do you mean by "top bar"? – musicamante Nov 06 '21 at 06:44
  • The bar which shows the current selected option, or the bar which is show when the dropdown is not active – BladeOfLightX Nov 06 '21 at 06:54
  • That "bar" *is* the combobox. You cannot use stylesheets to change the position of the popup, as they are actually two different widget, even if they are part of the same component, and the position is decided by the current OS/style. See the answer to this related question: [PyQt5 QComboBox list items changing postion](https://stackoverflow.com/a/60531114); it's about a different problem, but the concept remains. – musicamante Nov 06 '21 at 18:17

0 Answers0