View Full Version : QColor PushButton
jmqt
16th June 2009, 20:34
I am wondering if anyone can assist me in changing the color of a button upon it being on and and off. so for example - when it is on its green however when it is off it is red.
I think in the older version of qt the QPushButton isOn assisted in this.
I have proved an example:
if (button->isDown())
button->setStyleSheet(QString("QPushButton {background-color: green;}"));
else
button->setStyleSheet(QString("QPushButton {background-color: red;}"));
}
Lykurg
16th June 2009, 20:45
Hi, have a look on the Pseudo-States of the qt style sheets!
(setCheckable() with : on)
jmqt
20th July 2009, 19:46
Could you possibly explain, since I have looked at it and am a little confuse. Are you suggesting if(button->setCheckable():on)?
wysota
20th July 2009, 22:00
More likely:
QPushButton:pressed { background-color:green; }
QPushButton { background-color: red; }
metdos
21st July 2009, 08:03
How can I apply coloring for specific push buttons? For example
QPushButton pushButton;
nish
21st July 2009, 08:04
use pushbutton.setStyleSheet()...
metdos
21st July 2009, 08:19
pushButton->setStyleSheet("background-color: red")
is ok for background, but how will I "pressed" part?
nish
21st July 2009, 08:20
put everything in just one string... study the style sheet example that comes with qt
bremer
21st July 2009, 10:30
pushButton->setStyleSheet("QPushButton:pressed { background-color: blue; }");
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.