void MainWidget::mouseMoveEvent(QMouseEvent *e) {
update();
}
I am guessing that this is the cause of your problem. You should not have to call update(), repaint(), or anything else in a mouse event. Qt takes care of whatever needs to be done in response to mouse move events to keep the window updated.