Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to properly style QComboBox and dropdown?
QtWS25 Last Chance

How to properly style QComboBox and dropdown?

Scheduled Pinned Locked Moved Unsolved General and Desktop
stylesheetcombobox stylecombobox macosdrop-downcombobox
3 Posts 2 Posters 4.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arjun98
    wrote on 28 Apr 2021, 02:22 last edited by
    #1

    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,
    Arjun

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nagesh
      wrote on 28 Apr 2021, 10:28 last edited by
      #2

      @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?
      https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox

      A 1 Reply Last reply 28 Apr 2021, 11:49
      0
      • N nagesh
        28 Apr 2021, 10:28

        @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?
        https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox

        A Offline
        A Offline
        arjun98
        wrote on 28 Apr 2021, 11:49 last edited by
        #3

        @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

        1 Reply Last reply
        0

        1/3

        28 Apr 2021, 02:22

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved