Trolltech Home | Qtopia-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qtopia-interest Archive, February 2008
[PATCH] QAnalogClock is drawing the clock face at the wrong position after resize


Message 1 in thread

Hello,

the face of the clock is scaled in the paintEvent. If the size is changing 
after the first paintEvent the face will be drawn at the wrong position as the 
resize is not taken into account. A test case should be easy to construct
and the proposed fixed is following.



From a66c0e4ca250ea6e937df2e726f3f62bc6673ea2 Mon Sep 17 00:00:00 2001
From: Holger Freyther <zecke@xxxxxxxxxxx>
Date: Tue, 19 Feb 2008 23:36:11 +0100
Subject: [PATCH] The Clock Face was drawn at the wrong position:
     The scaledFace was only calculated once. If the size changed
     after the first paintEvent the scaledFace had the wrong size
     and was shown at the wrong position.
     Throw the scaledFace away in the resizeEvent and the face will
     be rescaled in the paintEvent.

---
 src/libraries/qtopia/qanalogclock.cpp |    9 +++++++++
 src/libraries/qtopia/qanalogclock.h   |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/libraries/qtopia/qanalogclock.cpp 
b/src/libraries/qtopia/qanalogclock.cpp
index 5fc92b8..53e36e6 100644
--- a/src/libraries/qtopia/qanalogclock.cpp
+++ b/src/libraries/qtopia/qanalogclock.cpp
@@ -144,6 +144,15 @@ void QAnalogClock::setFace( const QPixmap& face )
 }
 
 /*!
+   \reimplementation
+*/
+void QAnalogClock::resizeEvent( QResizeEvent *event )
+{
+    d->scaledFace = QPixmap();
+    QFrame::resizeEvent(event);
+}
+
+/*!
     \internal
 */
 void QAnalogClock::paintEvent( QPaintEvent *event )
diff --git a/src/libraries/qtopia/qanalogclock.h 
b/src/libraries/qtopia/qanalogclock.h
index 4703291..65220a8 100644
--- a/src/libraries/qtopia/qanalogclock.h
+++ b/src/libraries/qtopia/qanalogclock.h
@@ -40,6 +40,7 @@ public:
     void setFace( const QPixmap& face );
 
 protected:
+    void resizeEvent( QResizeEvent* event );
     void paintEvent( QPaintEvent *event );
     void drawContents( QPainter *p );
     void drawHand( QPainter *p, QPoint, QPoint );
-- 
 [ signature omitted ]