changing button background color
Hello!
I've got some buttons on my main window. Each button is setting page on QStackedWidget. I want to change color of a button which was clicked. Is there any other way than using setStyleSheet? I'm asking because my stylesheet is quite complicated, and I want to change just background color. Any ideas?
thanks in advance
best regards
Tomasz
Re: changing button background color
hi,
u can use QPalette
Code:
p.
setBrush(QPalette::Button,Qt
::yellow);
p.
setBrush(QPalette::ButtonText, Qt
::blue);
b->setPalette(p);
hope it helps
bala
Re: changing button background color
Third party here:
That will make the button a solid color, is there a way to change the button color with shades, so it looks like a modern button. Like it does by default, except chaning the theme color.
Any suggestions?
Re: changing button background color
There is no simple way to do this with palettes or stylesheets. On some operating systems it will work, but others (<cough>Windows<cough>) do not allow button backgrounds to be altered. The only foolproof way to do this is to derive your own button class and override the paint method.
Re: changing button background color
Quote:
Third party here:
That will make the button a solid color, is there a way to change the button color with shades, so it looks like a modern button. Like it does by default, except chaning the theme color.
Any suggestions?
To make the shade in buttons , u can use stylesheets's transparent property or u can design ur own images and apply to the button;
for Gradient:
Code:
QLinearGradient( x1
: 0, y1
: 0, x2
: 0, y2
: 1, stop
: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c);
for images :
Code:
background-image: url(/path/to/image.png);
Hope it helps
Bala