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. How do I change the colour of the text of a CheckBox?
QtWS25 Last Chance

How do I change the colour of the text of a CheckBox?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k 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
    Dugi
    wrote on 13 Nov 2013, 22:26 last edited by
    #1

    Sorry for annoying again, but I've tried all things I have found, and neither of them seemed to work.

    I need to match some colours to some checkboxes. I have read that stylesheets don't work here, HTML formatting neither, and the only other solution was modifying the palette. I have tried to do it inQtDesigner, and it worked, but I can't find a way to do it dynamically.

    My code (doesn't crash, does nothing):
    @ QPalette palette = (*lines[i]).palette();
    palette.setColor(QPalette::WindowText,generateColour(i)); //Generates a valid colour
    (*lines[i]).setPalette(palette);@

    Can you help me, please?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on 14 Nov 2013, 00:55 last edited by
      #2

      You should use stylesheet. Parts of QPalette will be ignored by some modern style such as XP/Vista/MacOS

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dugi
        wrote on 14 Nov 2013, 06:07 last edited by
        #3

        I'm not using newer Windows or Mac, I am using Linux, but it seems that the palette is ignored anyway. I'll try that stylesheet, I hope that I was wrong when reading that it can't be used.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 14 Nov 2013, 08:27 last edited by
          #4

          maybe you use the wrong palette role. Did you try QPalette::ButtonText or QPalette::Text?
          I can't remember which roles assign which color and i never will i think ... :)

          --- 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
          • D Offline
            D Offline
            Dugi
            wrote on 14 Nov 2013, 18:06 last edited by
            #5

            @1+1=2
            I could only change the background colour, though, changing the text colour or anything else didn't seem to work (just did nothing). I think that linux's window manager is to blame.

            @raven-worx
            I had tried also the palette roles you suggested, but neither of them had any effect. Style sheet was the only thing capable of colouring something on these checkboxes.

            Thanks for the help. Is there a way to give you a kudos?

            1 Reply Last reply
            0

            2/5

            14 Nov 2013, 00:55

            • Login

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