I guess your MainWindow is derived from QMainWindow...
AFAIK this may be expected behaviour, though the behaviour depends on the platform and possibly other things. QMainWindow is not supposed to be painted on directly. You should paint on a child widget.
...By googling about it you should have noticed that you are not among the first to ask about this...