diff options
Diffstat (limited to 'examples/opengl')
-rw-r--r-- | examples/opengl/hellowindow/hellowindow.cpp | 13 | ||||
-rw-r--r-- | examples/opengl/hellowindow/hellowindow.h | 2 | ||||
-rw-r--r-- | examples/opengl/hellowindow/main.cpp | 8 | ||||
-rw-r--r-- | examples/opengl/paintedwindow/paintedwindow.cpp | 18 |
4 files changed, 22 insertions, 19 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); } diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 911011a303..0920e6e89d 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -56,7 +56,7 @@ PaintedWindow::PaintedWindow() format.setSamples(4); setSurfaceType(QWindow::OpenGLSurface); - setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); setFormat(format); create(); @@ -70,12 +70,12 @@ PaintedWindow::PaintedWindow() m_animation->setEndValue(qreal(1)); m_animation->setDuration(500); - requestWindowOrientation(Qt::PortraitOrientation); + requestOrientation(Qt::PortraitOrientation); QRect screenGeometry = screen()->availableGeometry(); QPoint center = screenGeometry.center(); - QRect windowRect = screen()->isLandscape(windowOrientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640); + QRect windowRect = screen()->isLandscape(orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640); setGeometry(QRect(center - windowRect.center(), windowRect.size())); m_rotation = 0; @@ -142,13 +142,13 @@ void PaintedWindow::orientationChanged(Qt::ScreenOrientation newOrientation) QPainter p; p.begin(&m_prevImage); - p.setTransform(screen()->transformBetween(contentOrientation(), windowOrientation(), rect)); - paint(&p, screen()->mapBetween(contentOrientation(), windowOrientation(), rect)); + p.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect)); + paint(&p, screen()->mapBetween(contentOrientation(), orientation(), rect)); p.end(); p.begin(&m_nextImage); - p.setTransform(screen()->transformBetween(newOrientation, windowOrientation(), rect)); - paint(&p, screen()->mapBetween(newOrientation, windowOrientation(), rect)); + p.setTransform(screen()->transformBetween(newOrientation, orientation(), rect)); + paint(&p, screen()->mapBetween(newOrientation, orientation(), rect)); p.end(); m_deltaRotation = screen()->angleBetween(newOrientation, contentOrientation()); @@ -207,9 +207,9 @@ void PaintedWindow::paint() painter.setOpacity(m_rotation); painter.drawImage(0, 0, m_nextImage); } else { - QRect mapped = screen()->mapBetween(contentOrientation(), windowOrientation(), rect); + QRect mapped = screen()->mapBetween(contentOrientation(), orientation(), rect); - painter.setTransform(screen()->transformBetween(contentOrientation(), windowOrientation(), rect)); + painter.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect)); paint(&painter, mapped); painter.end(); } |