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,11 +92,13 @@ public:
} }
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE { void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE {
if (!m_mouseDown) {
m_mouseDown = true; m_mouseDown = true;
m_polygon.clear(); m_polygon.clear();
m_polygon.append(e->pos()); m_polygon.append(e->pos());
renderLater(); renderLater();
} }
}
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE { void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE {
if (m_mouseDown) { if (m_mouseDown) {
@ -106,10 +108,12 @@ public:
} }
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE { void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE {
if (m_mouseDown) {
m_mouseDown = false; m_mouseDown = false;
m_polygon.append(e->pos()); m_polygon.append(e->pos());
renderLater(); renderLater();
} }
}
void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE { void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE {
m_focus = true; m_focus = true;