Important: Please read the Qt Code of Conduct -

avoiding styleSheet inheritance

  • I'm applying styles to some widgets. I have 3 "boxes", created with a QWidget each, and I want them to have rounded corners and a different background color.

    Inside each one, I need to have different widgets, and I'm using layouts for this.

    It happens that all the children of one QWidget inherit the parent styles.
    For example I use:
    widget->setStylesheet( "background-color: #edcba9; border-radius: 10px;")

    Is it possible to set a styleSheet that has no effects on children objects?

    I have some other style-related problems but I think they are all related to inheritance, for example I need to specify new style for QToolButtons since they lose any animation (hover, pressed, etc) when children of a styled widget.

  • Lifetime Qt Champion


    You can use e.g. an id selector for that

    Hope it helps

Log in to reply