diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /examples/opengl/hellowindow | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
Diffstat (limited to 'examples/opengl/hellowindow')
-rw-r--r-- | examples/opengl/hellowindow/hellowindow.cpp | 13 | ||||
-rw-r--r-- | examples/opengl/hellowindow/hellowindow.h | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index a978e19b79..1c1259de13 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -98,6 +98,15 @@ void HelloWindow::exposeEvent(QExposeEvent *) m_renderer->render(); } +bool HelloWindow::event(QEvent *ev) +{ + if (ev->type() == QEvent::UpdateRequest) { + m_renderer->render(); + requestUpdate(); + } + return QWindow::event(ev); +} + void HelloWindow::mousePressEvent(QMouseEvent *) { updateColor(); @@ -132,7 +141,7 @@ void Renderer::setAnimating(HelloWindow *window, bool animating) if (animating) { m_windows << window; if (m_windows.size() == 1) - QTimer::singleShot(0, this, &Renderer::render); + window->requestUpdate(); } else { m_currentWindow = 0; m_windows.removeOne(window); @@ -196,8 +205,6 @@ void Renderer::render() m_context->swapBuffers(surface); m_fAngle += 1.0f; - - QTimer::singleShot(0, this, &Renderer::render); } Q_GLOBAL_STATIC(QMutex, initMutex) diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h index e92e45a125..e6d7970cfc 100644 --- a/examples/opengl/hellowindow/hellowindow.h +++ b/examples/opengl/hellowindow/hellowindow.h @@ -112,11 +112,12 @@ public: QColor color() const; void updateColor(); +protected: + bool event(QEvent *ev) override; void exposeEvent(QExposeEvent *event) override; - -private: void mousePressEvent(QMouseEvent *) override; +private: int m_colorIndex; QColor m_color; const QSharedPointer<Renderer> m_renderer; |