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. QComboBox + QSS + setting text color [Solved]
Forum Updated to NodeBB v4.3 + New Features

QComboBox + QSS + setting text color [Solved]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 9.8k Views 1 Watching
  • 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Hi! Surely an easy question here...

    I'm changing the text color of a QComboBox using a style sheet from black to white. The problem I'm facing is that, when the QComboBox contents drop down, the (white) text can't be read due to the also white background.

    So... how can I change the text color of current AND any other option of the QComboBox? Or, conversely, how can I change the background color only when the QComboBox is "on" (drop-down'd)?

    EDIT: for example: Normally, the QComboBox has white text, grey background. When drop-down'd, it has white text and white background. I would like it to have black text and white background when drop-down'd. Also could do great with white text and grey background.

    Thanks a million!

    --

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      The drop down is a QListView that is a child of the QComboBox. That means that you can also style it as such. See the documentation for the styleable properties of QListView.

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        Back here again, ready to tag the post as SOLVED!

        This piece of QSS sets the text's color to black, while the background remains white.

        @QComboBox QListView {
        color: black;
        /*alternate-background-color: green;
        }@

        (thanks, Andre!!)

        --

        1 Reply Last reply
        1
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You can add that tag yourself. Simply edit your first message, and modify the subject line. I've done it for you this time, but next time, please do that yourself. Glad you got your issue solved!

          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