Compare what I wrote:
remove the style sheet from Dialog1.ui and modify the palette in Designer so that QPalette::Window is Red.
to what you did in your code:
Qt Code:
  1. QPalette pal = palette();
  2. pal.setColor(QPalette::Background, Qt::red);
To copy to clipboard, switch view to plain text mode 

You can actually make that palette adjustment to QPalette::Window in Designer if you wish. The QPalette::Window comes from the docs linked earlier.

The other thing I did in your project was apply a layout to everything in your Dialog1. I do not think this will make a difference to the painting only the layout and usability.