Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to style a disabled item in a QComboBox ? (qss)
Qt 6.12 LTS is out! See what's new in the release blog

How to style a disabled item in a QComboBox ? (qss)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 4.6k 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.
  • J Offline
    J Offline
    julia_f
    wrote on last edited by
    #1

    I used this code to disable an item inside a combobox : https://stackoverflow.com/questions/38915001/disable-specific-items-in-qcombobox
    I can disable specific items in QComboBox (it's ok)

    And I would like a visual feedback. I would like to put the text of the disabled item in red.

    I tried this code but it doesn't nothing.

    QComboBox::item:!enabled
    {
    color:red;
    }
    

    I think that it's somewhere in the drop-down. But this code doesn't work also :

    QComboBox::drop-down:item:!enabled {
    color:red;
    }
    
    raven-worxR 1 Reply Last reply
    0
    • J julia_f

      I used this code to disable an item inside a combobox : https://stackoverflow.com/questions/38915001/disable-specific-items-in-qcombobox
      I can disable specific items in QComboBox (it's ok)

      And I would like a visual feedback. I would like to put the text of the disabled item in red.

      I tried this code but it doesn't nothing.

      QComboBox::item:!enabled
      {
      color:red;
      }
      

      I think that it's somewhere in the drop-down. But this code doesn't work also :

      QComboBox::drop-down:item:!enabled {
      color:red;
      }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @julia_f

      QComboBox QAbstractItemView::item:!enabled
      {
          color:red;
      }
      

      --- 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
      3
      • Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by Cobra91151
        #3

        Try my code. It will style the disabled combobox items.

        QComboBox QAbstractItemView::disabled {
            color: #FF0000;
        }
        
        1 Reply Last reply
        1

        • Login

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