From 1adedb7baad717bd6f41796ccc717ba93e2f3738 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 11 May 2015 14:29:17 +0200 Subject: Make the windowcontainer example more robust The QWindow tends to get mouse releases on Windows when maximizing the window for example. This is likely a problem in the platform, but the example should be improved too to be more robust and ignore such unwanted events. Task-number: QTBUG-42842 Change-Id: Iecf916a2f753ed1b37d644721ee212ca7c728c49 Reviewed-by: Friedemann Kleint --- examples/widgets/windowcontainer/windowcontainer.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/widgets/windowcontainer/windowcontainer.cpp b/examples/widgets/windowcontainer/windowcontainer.cpp index 022b6dafc4..a38a10e6f6 100644 --- a/examples/widgets/windowcontainer/windowcontainer.cpp +++ b/examples/widgets/windowcontainer/windowcontainer.cpp @@ -92,10 +92,12 @@ public: } void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE { - m_mouseDown = true; - m_polygon.clear(); - m_polygon.append(e->pos()); - renderLater(); + if (!m_mouseDown) { + m_mouseDown = true; + m_polygon.clear(); + m_polygon.append(e->pos()); + renderLater(); + } } void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE { @@ -106,9 +108,11 @@ public: } void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE { - m_mouseDown = false; - m_polygon.append(e->pos()); - renderLater(); + if (m_mouseDown) { + m_mouseDown = false; + m_polygon.append(e->pos()); + renderLater(); + } } void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE { -- cgit v1.2.3