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?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.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.
  • D Offline
    D Offline
    Dugi
    wrote on 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 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 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
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on 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 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

            • Login

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