View Full Version : color one half of the button?
tommy
26th December 2007, 15:34
Hello,
I know how to change the background color of a pushbutton:
colorButton->setStyleSheet("background:rgb(100,150,200);");
But is it also possible, using style sheets, to make one half of the button one color
and the second half another color? How?
jpn
26th December 2007, 15:44
Yes, use gradient (http://doc.trolltech.com/latest/stylesheet-reference.html#gradient).
wysota
26th December 2007, 15:46
Yes... it is possible using a linear gradient. But.... what for?
tommy
26th December 2007, 18:00
Thanks!
I don't really want gradient, I need left side of the button to be one color and
right side a different color with a sharp border. How would you do that? Are there any examples out there with the syntax?
jpn
26th December 2007, 19:42
I don't really want gradient, I need left side of the button to be one color and right side a different color with a sharp border. How would you do that? Are there any examples out there with the syntax?
A linear gradient is still fine. Remember, you can define a color at any stop. Try something like:
QPushButton {
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
stop:0.5 red, stop:0.5 blue);
border: ...
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.