Qt World Summit: Submit your Presentation

How to properly style QComboBox and dropdown?

  • I have been trying to style the QCombobox and its dropdown, however, the dropdown is not styled as I expected. I have followed tutorials however the results are not as expected.
    Desired Result:
    Dropdown when closed
    Screen Shot 2021-04-27 at 10.11.16 PM.png

    Dropdown when open:
    Screen Shot 2021-04-27 at 10.11.26 PM.png

    However, the result I am getting is something like this:
    Screen Shot 2021-04-27 at 10.16.59 PM.png

    Screen Shot 2021-04-27 at 10.17.06 PM.png

    As you can see, the drop-down width does not match the original Combobox width.
    The second issue is that if a lower option is selected the whole dropdown shifts:

    Screen Shot 2021-04-27 at 10.18.59 PM.png

    I have looked through the QComboBox stylesheet guide provided by Qt but have found nothing that has helped.
    I am currently working on a macOS if that makes a difference.

    Thank you for your help,

  • @arjun98 Do you have any layout set for combo box in the dialog?
    Horizontal width of combobox might be because of Horizontal policy set for combobox

    What styling you have used for combobox?

  • @nagesh No style sheet, however, I had experiemented with the stylesheet in the link that you sent, and I couldn't figure it out. Which fields pertain to the width of the drop-down?

    There is a horizontal layout, however, I have also tried without layout and I get the same issue.
    I can control the width of the Combobox when it is closed, but once open there is an offset, that is what I would like to remove.

    Thank you,