style sheet and colors that change dynamically when a field is enabled or disabled

  • Hi

    I am trying to change the colors for certain widgets. For the "enabled" state, the widget will be blue and for the "disabled" state they will be in color that is between blue and gray.
    My code looks like this :

                    "QWidget[enabled=\"false\"] {color: #64B2D1;}"
                    "QWidget{color: blue;}");

    It works fine initially but for instance, when a disabled widget is enabled, the color does not change and stays grayish.
    What should I do to make this color effect dynamic.


  • @gautiery

    After changing a property you have to update the style() of your widget


  • Qt Champions 2018

    if instead of checking the property you use the pseudo-state it should work

    "QWidget:disabled{color: #64B2D1;}"
    "QWidget{color: blue;}");

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.