I would like to change a backcolor theme of a QPushButton being Pressed. I am using QT Creator 2 and Windows 7. Here is the code. I tried using the StyleSheet option and it works fine, but in this case I will have a color dialog that will return the color that the button will need to change to. I would like the color not be solid, but gradient like it is by default but with a different themeColor.
QPushButton *button
= this
->findChild<QPushButton
*>
(text
);
if ( button->text() != "Pressed")
{
button->setText("Pressed");
theColorPicked
= myColorDialog
->getColor
(QColor(0,
0,
0));
thePal.setColor(button->backgroundRole(),theColorPicked);
button->setPalette(thePal);
QPushButton *button = this->findChild<QPushButton *>(text);
if ( button->text() != "Pressed")
{
button->setText("Pressed");
QColorDialog *myColorDialog;
QColor theColorPicked;
QPalette thePal;
theColorPicked = myColorDialog->getColor(QColor(0,0,0));
thePal.setColor(button->backgroundRole(),theColorPicked);
button->setPalette(thePal);
To copy to clipboard, switch view to plain text mode
Bookmarks