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. Setting QComboBox stylesheet reduces hight of dropdown [SOLVED]
QtWS25 Last Chance

Setting QComboBox stylesheet reduces hight of dropdown [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.2k 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.
  • R Offline
    R Offline
    rherzog
    wrote on last edited by
    #1

    Hi all,

    I want my combobox to be blue. That is achieved by setting the stylesheet:
    @combo->setStyleSheet("color: blue");@

    There is only one downside:
    Setting the above styling reduces the amount of items displayed when the combobox is clicked on the subitem list is displayed.
    https://skydrive.live.com/redir?resid=47024E7C0E1A51D7!6780&v=3

    What can I do to set the textcolor and have all subitems of the combobox displayed when I click on the combobox.

    kind regards, reinhart

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you can try this:
      @
      QAbstractItemView * view = combo->view();
      QPalette p = view->palette();
      p.setColor(QPalette::Text,Qt::blue);
      view->setPalette(p);
      @
      Not tested though.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rherzog
        wrote on last edited by
        #3

        Thanks a lot - works nicely!

        1 Reply Last reply
        0
        • N Offline
          N Offline
          NicuPopescu
          wrote on last edited by
          #4

          qss for combo should not affect the number of visible items

          where/when do you apply the style sheet?

          just in case you could control the number of max visible items, after the style sheet setting, with:

          @ui->comboBox->setMaxVisibleItems(5);@

          or

          @ui->comboBox->setStyleSheet("qproperty-maxVisibleItems:3");@

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rherzog
            wrote on last edited by
            #5

            Hi,
            the combobox is part of a QTableWidget. I think setting the stylesheet overwrites some default stylings (at least that is my explaination I don't know if that's true).
            Thanks for the hint with maxvisible item, though!
            regards, reinhart

            1 Reply Last reply
            0

            • Login

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