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 foregroun color not displayed in main widget
Forum Update on Monday, May 27th 2025

QComboBox foregroun color not displayed in main widget

Scheduled Pinned Locked Moved Solved General and Desktop
qcombobox
3 Posts 2 Posters 419 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by Dariusz
    #1

    Hey

    I'm trying to set different color of text per item. However when the item gets picked the color is still as "standard" and not the one I set.. Any hints?

        self.comboTest = QComboBox()
        self.comboTest.addItems(["test A", "testB", "testC"])
        self.comboTest.setItemData(1, QBrush(Qt.red),Qt.ForegroundRole )
        self.comboTest.setItemData(2, QBrush(Qt.blue), Qt.ForegroundRole )
    

    Any ideas?

    TIA

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      That sets the colors when drawn.
      It sounds like you want to also change the selection color ?

      https://forum.qt.io/topic/108718/change-qcombobox-popup-highlighted-item-background-color/12

      D 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        That sets the colors when drawn.
        It sounds like you want to also change the selection color ?

        https://forum.qt.io/topic/108718/change-qcombobox-popup-highlighted-item-background-color/12

        D Offline
        D Offline
        Dariusz
        wrote on last edited by Dariusz
        #3

        @mrjj said in QComboBox foregroun color not displayed in main widget:

        Hi
        That sets the colors when drawn.
        It sounds like you want to also change the selection color ?

        https://forum.qt.io/topic/108718/change-qcombobox-popup-highlighted-item-background-color/12

        So in a "human" test it works, if I set it, it works properly. But when I try to load my settings and set it "programmatically", even tho it says it sets pallets (btw I had to use ButtonText). Then it does not work... sigh. Its bananas. Will try to make simple examples.

        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