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.

Qt Code:
  1. QPushButton *button = this->findChild<QPushButton *>(text);
  2. if ( button->text() != "Pressed")
  3. {
  4. button->setText("Pressed");
  5.  
  6. QColorDialog *myColorDialog;
  7. QColor theColorPicked;
  8. QPalette thePal;
  9.  
  10. theColorPicked = myColorDialog->getColor(QColor(0,0,0));
  11. thePal.setColor(button->backgroundRole(),theColorPicked);
  12. button->setPalette(thePal);
To copy to clipboard, switch view to plain text mode