I have several buttons on my application that have their background color set dynamically during runtime to reflect associated displayed data. This works fine - on some platforms. On others, the button background refuses to change. I'm not using stylesheets - I use the following construct:

Qt Code:
  1. QPalette p = visibleButton->palette();
  2. p.setColor(QPalette::Button, newColor);
  3. visibleButton->setPalette(p);
To copy to clipboard, switch view to plain text mode 

I've also tried placing a small, blank label next to the button and changing it's background color using the same approach. This also fails on some platforms but succeeds on others.

What is the recommended way of setting the background color of a button, or a widget in general, that will work everywhere?