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
Dropdown when open:
However, the result I am getting is something like this:
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: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,
Arjun -
@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 comboboxWhat styling you have used for combobox?
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox -
@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,
Arjun