repaint and paintEvent are completely unrelated to the problem. They have nothing to do with dimensions of your window.