summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-09-14 15:14:32 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-08-30 04:12:01 +0000
commitd2c05b0c8557625ce45cdbd98ebf102972d2c2f4 (patch)
tree4cf778f249df164b35dd1ea3d5b482506244de73 /examples/widgets/widgets
parent09f59271e677259e1e2ffd3b42fff107001f89a5 (diff)
Tablet example: paint only the changed areas of the canvas
This improves performance significantly. Change-Id: I9a8782148ce03a2bc85759c4e8c1eecb37467cf6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp
index 3ff26d2ec8..bfcc84e182 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp
@@ -148,12 +148,14 @@ void TabletCanvas::initPixmap()
m_pixmap = newPixmap;
}
-void TabletCanvas::paintEvent(QPaintEvent *)
+void TabletCanvas::paintEvent(QPaintEvent *event)
{
if (m_pixmap.isNull())
initPixmap();
QPainter painter(this);
- painter.drawPixmap(0, 0, m_pixmap);
+ QRect pixmapPortion = QRect(event->rect().topLeft() * devicePixelRatioF(),
+ event->rect().size() * devicePixelRatioF());
+ painter.drawPixmap(event->rect().topLeft(), m_pixmap, pixmapPortion);
}
//! [4]