From 5f41df571714fc2e43452b58f679fdc5012f6b29 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Tue, 22 May 2018 16:07:53 +0200 Subject: [PATCH] Fix repaint logic Nowadays everything is buffered and composed, so we have to request that the widget should be repainted later. --- t14/cannon.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/t14/cannon.cpp b/t14/cannon.cpp index c0b5f42..68b9a95 100644 --- a/t14/cannon.cpp +++ b/t14/cannon.cpp @@ -39,7 +39,7 @@ void CannonField::setAngle( int degrees ) if ( ang == degrees ) return; ang = degrees; - repaint( cannonRect(), false ); + update( cannonRect() ); emit angleChanged( ang ); } @@ -72,10 +72,10 @@ void CannonField::newTarget() QTime midnight( 0, 0, 0 ); srand( midnight.secsTo(QTime::currentTime()) ); } - erase( targetRect() ); + update( targetRect() ); target = QPoint( 200 + rand() % 190, 10 + rand() % 255 ); - repaint( targetRect() ); + update( targetRect() ); } void CannonField::setGameOver() @@ -85,7 +85,7 @@ void CannonField::setGameOver() if ( shooting ) stopShooting(); gameEnded = true; - repaint(); + update(); } void CannonField::restartGame() @@ -93,12 +93,12 @@ void CannonField::restartGame() if ( shooting ) stopShooting(); gameEnded = false; - repaint(); + update(); } void CannonField::timerEvent( QTimerEvent * ) { - erase( shotRect() ); + update( shotRect() ); timerCount++; QRect shotR = shotRect(); @@ -114,7 +114,7 @@ void CannonField::timerEvent( QTimerEvent * ) emit missed(); return; } - repaint( shotR, false ); + update( shotR ); } void CannonField::paintEvent( QPaintEvent *e ) -- GitLab