summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow
diff options
context:
space:
mode:
Diffstat (limited to 'examples/opengl/hellowindow')
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp13
-rw-r--r--examples/opengl/hellowindow/hellowindow.h2
-rw-r--r--examples/opengl/hellowindow/main.cpp8
3 files changed, 13 insertions, 10 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 3c314d9bc2..b5166abe50 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -60,11 +60,10 @@ Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *scree
}
HelloWindow::HelloWindow(const QSharedPointer<Renderer> &renderer)
- : m_colorIndex(0)
- , m_renderer(renderer)
+ : m_colorIndex(0), m_renderer(renderer), m_timer(0)
{
setSurfaceType(QWindow::OpenGLSurface);
- setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
+ setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
setGeometry(QRect(10, 10, 640, 480));
@@ -84,9 +83,11 @@ void HelloWindow::exposeEvent(QExposeEvent *event)
render();
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(render()));
- timer->start(10);
+ if (!m_timer) {
+ m_timer = new QTimer(this);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(render()));
+ m_timer->start(10);
+ }
}
void HelloWindow::mousePressEvent(QMouseEvent *)
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
index a3e9fc5f96..adb85c1a6e 100644
--- a/examples/opengl/hellowindow/hellowindow.h
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -49,6 +49,7 @@
QT_BEGIN_NAMESPACE
class QOpenGLContext;
+class QTimer;
QT_END_NAMESPACE
class Renderer : public QObject
@@ -107,4 +108,5 @@ private:
int m_colorIndex;
QColor m_color;
const QSharedPointer<Renderer> m_renderer;
+ QTimer *m_timer;
};
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
index 618a499286..343160f755 100644
--- a/examples/opengl/hellowindow/main.cpp
+++ b/examples/opengl/hellowindow/main.cpp
@@ -71,7 +71,7 @@ int main(int argc, char **argv)
HelloWindow *windowA = new HelloWindow(rendererA);
windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
- windowA->setWindowTitle(QLatin1String("Thread A - Context A"));
+ windowA->setTitle(QLatin1String("Thread A - Context A"));
windowA->setVisible(true);
windows.prepend(windowA);
@@ -85,13 +85,13 @@ int main(int argc, char **argv)
HelloWindow *windowB = new HelloWindow(rendererA);
windowB->setGeometry(QRect(center, windowSize).translated(delta / 2, 0));
- windowB->setWindowTitle(QLatin1String("Thread A - Context A"));
+ windowB->setTitle(QLatin1String("Thread A - Context A"));
windowB->setVisible(true);
windows.prepend(windowB);
HelloWindow *windowC = new HelloWindow(rendererB);
windowC->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta));
- windowC->setWindowTitle(QLatin1String("Thread B - Context B"));
+ windowC->setTitle(QLatin1String("Thread B - Context B"));
windowC->setVisible(true);
windows.prepend(windowC);
@@ -113,7 +113,7 @@ int main(int argc, char **argv)
window->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, -windowSize.height() / 2));
QChar id = QChar('B' + i);
- window->setWindowTitle(QLatin1String("Thread ") + id + QLatin1String(" - Context ") + id);
+ window->setTitle(QLatin1String("Thread ") + id + QLatin1String(" - Context ") + id);
window->setVisible(true);
windows.prepend(window);
}