Change ONLY the background color of a QFrame, not everything in it.
I have a QFrame that I want to change the background color.
I do so using the following:
my_qframe->setStyleSheet("background-color:yellow;");
Which works -- to a point
I have several buttons in that frame. I do not want their colors changed, but they do change.
Is there a way around this?
Thank You
emp1953
Re: Change ONLY the background color of a QFrame, not everything in it.
Quote:
Originally Posted by
emp1953
I have a QFrame that I want to change the background color.
...
Perhaps:
Code:
my_qframe->setStyleSheet("QFrame { background-color:yellow; }");
Re: Change ONLY the background color of a QFrame, not everything in it.
Quote:
Originally Posted by
ChrisW67
Perhaps:
Code:
my_qframe->setStyleSheet("QFrame { background-color:yellow; }");
Thank you this worked perfectly. How do I mark this solved?
Added after 13 minutes:
chrisw67, It seems to work only if buttons are in the qframe. Some of the frames have listwidgets and they turn green and stay that way. Do I have to take an additional step and use a stylesheet to turn them back?
Re: Change ONLY the background color of a QFrame, not everything in it.
The list widget will not be going green because of the QFrame style above, which only mentions yellow. The QListWidget class inherits from QFrame so it can be affected by a style selector "QFrame". You can change that behaviour by changing the selector:
Code:
my_qframe->setStyleSheet(".QFrame { background-color:yellow; }");
See Qt5 Style Sheet Syntax esp. under Selector Types heading.
Where else are you applying style sheets? They cascade down to contained widgets, so it may be a parent widget with a style sheet that is driving this.