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 <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2015-05-11 14:29:17 +02:00
parent 62f24f04bf
commit 1adedb7baa

View File

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