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

change disabled background color QCheckbox?

Scheduled Pinned Locked Moved Solved General and Desktop
qcheckboxbackgroundcolor
4 Posts 3 Posters 3.9k 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.
  • pauleddP Offline
    pauleddP Offline
    pauledd
    wrote on 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.HilkJ 1 Reply Last reply
    0
    • pauleddP pauledd

      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.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on 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
      • pauleddP Offline
        pauleddP Offline
        pauledd
        wrote on 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.

        JonBJ 1 Reply Last reply
        1
        • pauleddP pauledd

          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.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #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

          • Login

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