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. change disabled background color QCheckbox?
QtWS25 Last Chance

change disabled background color QCheckbox?

Scheduled Pinned Locked Moved Solved General and Desktop
qcheckboxbackgroundcolor
4 Posts 3 Posters 3.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.
  • P Offline
    P Offline
    pauledd
    wrote on 11 Nov 2019, 07:55 last edited by
    #1

    Hi

    Is it possible to change the standard gray-ish background color of a
    QCheckBox::setEnabled(0)?
    Bildschirmfoto_2019-11-11_08-40-57.png

    I tried to set the background via:

    QCheckbox::setStyleSheet("QCheckBox::indicator {background-color:red;}");
    

    but that fills the whole checkbox with that color including the border and the checkmark itself.

    Bildschirmfoto_2019-11-11_08-54-13.png

    J 1 Reply Last reply 11 Nov 2019, 07:59
    0
    • P pauledd
      11 Nov 2019, 07:55

      Hi

      Is it possible to change the standard gray-ish background color of a
      QCheckBox::setEnabled(0)?
      Bildschirmfoto_2019-11-11_08-40-57.png

      I tried to set the background via:

      QCheckbox::setStyleSheet("QCheckBox::indicator {background-color:red;}");
      

      but that fills the whole checkbox with that color including the border and the checkmark itself.

      Bildschirmfoto_2019-11-11_08-54-13.png

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 11 Nov 2019, 07:59 last edited by
      #2

      hi @pauledd

      haven't checked it, but using the disabled keyword should work as a selector:

      QCheckBox::indicator:disabled{...}
      

      or simply

      QCheckBox:disabled {...}
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • P Offline
        P Offline
        pauledd
        wrote on 11 Nov 2019, 08:27 last edited by
        #3

        Thanks, with

        QCheckBox:disabled {background-color:red;}
        

        I get this:
        Bildschirmfoto_2019-11-11_09-19-10.png
        and with

        QCheckBox:disabled {color:green;background-color:red;}
        

        this:
        Bildschirmfoto_2019-11-11_09-22-08.png
        still weird looking but I can live with that...
        Thank you.

        J 1 Reply Last reply 11 Nov 2019, 08:31
        1
        • P pauledd
          11 Nov 2019, 08:27

          Thanks, with

          QCheckBox:disabled {background-color:red;}
          

          I get this:
          Bildschirmfoto_2019-11-11_09-19-10.png
          and with

          QCheckBox:disabled {color:green;background-color:red;}
          

          this:
          Bildschirmfoto_2019-11-11_09-22-08.png
          still weird looking but I can live with that...
          Thank you.

          J Offline
          J Offline
          JonB
          wrote on 11 Nov 2019, 08:31 last edited by JonB 11 Nov 2019, 08:41
          #4

          @pauledd
          You mean the background color "overspill" to right & bottom? I don't know but you might play with border-... or padding-... (I'm thinking margin- does not use background color, but I might be wrong) having a width/transparency/grey....

          1 Reply Last reply
          0

          1/4

          11 Nov 2019, 07:55

          • Login

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