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>
This commit is contained in:
Tor Arne Vestbø 2018-03-20 16:40:08 +01:00
parent ea60b4eb9a
commit 9c17b8adb9
2 changed files with 2 additions and 5 deletions

View File

@ -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

View File

@ -83,8 +83,6 @@ void RasterWindow::renderLater()
void RasterWindow::resizeEvent(QResizeEvent *resizeEvent)
{
m_backingStore->resize(resizeEvent->size());
if (isExposed())
renderNow();
}
//! [5]