[Solved] Change color of push button
-
wrote on 31 Dec 2013, 16:20 last edited by
Hi Folks,
I would like to create a pushBotton on my UI, but I need to change its color by specific user action. The first, I tried to change it on the UI designer: I clicked on the styleSheet property, but the setted color doesn't have any affect.
Can anybody help me, how can I change the color?Regards,
Norbert -
wrote on 31 Dec 2013, 16:39 last edited by
I put the following in the styleSheet property of a push button and it worked for me.
@background-color: rgb(255, 43, 39);@
-
wrote on 31 Dec 2013, 19:19 last edited by
Hi,
this also works for me, but I only see this color when the button is pressed. After the release the button color set back to the default.
Regards,
Norbert -
wrote on 31 Dec 2013, 19:21 last edited by
Can you post exactly what your stylesheet looks like?
-
wrote on 1 Jan 2014, 13:09 last edited by
Hi,
if I open the styleSheet editor, I see the following line:
@
color: rgb(97, 255, 24);
@This is some green color, but my buttons appers with the default grey color.
Regards,
NorbertUpdate:
I found the following solution that works for me (little bit in pseudo code):
@
QPushButton instance->setStyleSheet("border: 1px; border-radius: 6px; background-color: " + QColor instance.name());
@The "simple" change of the background-color didn't work, because the "border" property was not specified.
Regards,
Norbert
2/5