I've looked at all the previous posts on how to change the color of a button that I could search and find, but they don't seem to work. I'm using Qt 5.4.1 VS 2013 and Windows 7. I'm trying to change the color of a button to green when checked. I've tried changing the color of QPalette::Button
Qt Code:
  1. OnButtonToggled(bool bChecked)
  2. {
  3. if(bChecked)
  4. {
  5. QPalette pal = button->palette();
  6. pal.setColor(QPalette::Button, Qt::green);
  7. button->setAutoFillBackground(true);
  8. button->setPalette(pal);
  9. button->update();
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 
All this does is give me a green border around the button.
Palette.jpg

I also tried changing the brush of QPallete::Button
Qt Code:
  1. OnButtonToggled(bool bChecked)
  2. {
  3. if(bChecked)
  4. {
  5. QPalette pal = button->palette();
  6. pal.setBrush(QPalette::Button, QBrush(Qt::green));
  7. button->setAutoFillBackground(true);
  8. button->setPalette(pal);
  9. button->update();
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 
but I get the same thing.

if I change the style sheet
Qt Code:
  1. button->setStyleSheet("background-color:green;");
To copy to clipboard, switch view to plain text mode 
it changes to a squared off button instead of the rounded button it used to be, which means it no longer matches all the other buttons in the window.
StyleSheet.jpg
To be honest, I don't understand why the palette option doesn't work. In all the previous posts I've read, that's what people did. If I remember right, I needed to change the color of a button a couple of years ago, and the palette method is how I did it. I was using Qt 4.3.1 and Windows XP at that time though.