diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-20 16:40:08 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-20 16:00:31 +0000 |
commit | 9c17b8adb940fc32b29fe8d012d76b5c1b78a90f (patch) | |
tree | d4da631e22ae2b39a614bd4143ed5e2e1157a0b5 | |
parent | ea60b4eb9a257a9b9b5713f01d2e69f5eba3f94d (diff) |
Update rasterwindow example to not render in resizeEvent
The resize event should not be used to draw, as there will be a follow-up
exposeEvent delivered just after, and we don't want to draw twice.
This is how QRasterWindow operates too, except it defers the backingstore
resize to beginPaint() instead of resizing in the reizeEvent.
It's also how QOpenGLWindow operates, which also has a note for the
virtual resizeGL method saying: "Scheduling updates from here is not
necessary. The windowing systems will send expose events that trigger
an update automatically."
Change-Id: I2a9740018508c2eb129149f53237ee8e378c03b1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | examples/gui/doc/src/rasterwindow.qdoc | 5 | ||||
-rw-r--r-- | examples/gui/rasterwindow/rasterwindow.cpp | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/examples/gui/doc/src/rasterwindow.qdoc b/examples/gui/doc/src/rasterwindow.qdoc index 36612e1707..0c52a62b8e 100644 --- a/examples/gui/doc/src/rasterwindow.qdoc +++ b/examples/gui/doc/src/rasterwindow.qdoc @@ -99,9 +99,8 @@ The resize event is guaranteed to be called prior to the window being shown on screen and will also be called whenever the window - is resized while on screen. We use this to resize the back buffer - and call renderNow() if we are visible to immediately update the - visual representation of the window on screen. + is resized while on screen. We use this to resize the back buffer, + and defer rendering to the corresponding/following expose event. \snippet rasterwindow/rasterwindow.cpp 3 diff --git a/examples/gui/rasterwindow/rasterwindow.cpp b/examples/gui/rasterwindow/rasterwindow.cpp index 3eacd20145..e240b7f31c 100644 --- a/examples/gui/rasterwindow/rasterwindow.cpp +++ b/examples/gui/rasterwindow/rasterwindow.cpp @@ -83,8 +83,6 @@ void RasterWindow::renderLater() void RasterWindow::resizeEvent(QResizeEvent *resizeEvent) { m_backingStore->resize(resizeEvent->size()); - if (isExposed()) - renderNow(); } //! [5] |