Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QComboBox foregroun color not displayed in main widget

    General and Desktop
    qcombobox
    2
    3
    171
    Loading More Posts
    • 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
      Dariusz last edited by Dariusz

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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 Reply Quote 2
        • D
          Dariusz @mrjj last edited by Dariusz

          @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 Reply Quote 0
          • First post
            Last post