summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-08-28 15:16:57 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-09-02 10:21:56 +0000
commitc726bc85da3921c6a31d4f7d014ddd8b8d7a3f88 (patch)
treeed9cef6e31acb5881a77473e4f12a90b3c9ea426
parent4b340402b97b83790b3d71a8244a246eec4f8abd (diff)
Port examples/opengl to new connection syntax.
Change-Id: I486a4a2326bf57ec5ea08bccdcef79c3e5553db5 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--examples/opengl/2dpainting/window.cpp4
-rw-r--r--examples/opengl/contextinfo/renderwindow.cpp2
-rw-r--r--examples/opengl/hellogles3/glwindow.cpp2
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp4
-rw-r--r--examples/opengl/hellowindow/main.cpp4
-rw-r--r--examples/opengl/paintedwindow/paintedwindow.cpp8
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.cpp37
-rw-r--r--examples/opengl/qopenglwindow/main.cpp8
-rw-r--r--examples/opengl/textures/window.cpp6
9 files changed, 38 insertions, 37 deletions
diff --git a/examples/opengl/2dpainting/window.cpp b/examples/opengl/2dpainting/window.cpp
index e10d862607..4734026dfb 100644
--- a/examples/opengl/2dpainting/window.cpp
+++ b/examples/opengl/2dpainting/window.cpp
@@ -66,8 +66,8 @@ Window::Window()
setLayout(layout);
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), native, SLOT(animate()));
- connect(timer, SIGNAL(timeout()), openGL, SLOT(animate()));
+ connect(timer, &QTimer::timeout, native, &Widget::animate);
+ connect(timer, &QTimer::timeout, openGL, &GLWidget::animate);
timer->start(50);
}
//! [0]
diff --git a/examples/opengl/contextinfo/renderwindow.cpp b/examples/opengl/contextinfo/renderwindow.cpp
index 9d7e2c450e..fefcf0e56d 100644
--- a/examples/opengl/contextinfo/renderwindow.cpp
+++ b/examples/opengl/contextinfo/renderwindow.cpp
@@ -221,5 +221,5 @@ void RenderWindow::render()
// only here to make the UI widgets more responsive on slower machines. We
// can afford it since our rendering is so lightweight.
const int interval = 5;
- QTimer::singleShot(interval, this, SLOT(render()));
+ QTimer::singleShot(interval, this, &RenderWindow::render);
}
diff --git a/examples/opengl/hellogles3/glwindow.cpp b/examples/opengl/hellogles3/glwindow.cpp
index ad654b854c..a0deb8ecfb 100644
--- a/examples/opengl/hellogles3/glwindow.cpp
+++ b/examples/opengl/hellogles3/glwindow.cpp
@@ -92,7 +92,7 @@ GLWindow::GLWindow()
rAnim->setLoopCount(-1);
rAnim->start();
- QTimer::singleShot(4000, this, SLOT(startSecondStage()));
+ QTimer::singleShot(4000, this, &GLWindow::startSecondStage);
}
GLWindow::~GLWindow()
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 7674ffaed8..bc58e1a0e4 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -119,7 +119,7 @@ void Renderer::setAnimating(HelloWindow *window, bool animating)
if (animating) {
m_windows << window;
if (m_windows.size() == 1)
- QTimer::singleShot(0, this, SLOT(render()));
+ QTimer::singleShot(0, this, &Renderer::render);
} else {
m_currentWindow = 0;
m_windows.removeOne(window);
@@ -184,7 +184,7 @@ void Renderer::render()
m_fAngle += 1.0f;
- QTimer::singleShot(0, this, SLOT(render()));
+ QTimer::singleShot(0, this, &Renderer::render);
}
Q_GLOBAL_STATIC(QMutex, initMutex)
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
index 716280aa5f..f665ee6fa8 100644
--- a/examples/opengl/hellowindow/main.cpp
+++ b/examples/opengl/hellowindow/main.cpp
@@ -121,13 +121,13 @@ int main(int argc, char *argv[])
}
for (int i = 0; i < renderThreads.size(); ++i) {
- QObject::connect(qGuiApp, SIGNAL(lastWindowClosed()), renderThreads.at(i), SLOT(quit()));
+ QObject::connect(qGuiApp, &QGuiApplication::lastWindowClosed, renderThreads.at(i), &QThread::quit);
renderThreads.at(i)->start();
}
// Quit after 10 seconds. For platforms that do not have windows that are closeable.
if (QCoreApplication::arguments().contains(QStringLiteral("--timeout")))
- QTimer::singleShot(10000, qGuiApp, SLOT(quit()));
+ QTimer::singleShot(10000, qGuiApp, &QCoreApplication::quit);
const int exitValue = app.exec();
diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp
index c67edb6f65..6b015bd2c3 100644
--- a/examples/opengl/paintedwindow/paintedwindow.cpp
+++ b/examples/opengl/paintedwindow/paintedwindow.cpp
@@ -83,9 +83,11 @@ PaintedWindow::PaintedWindow()
m_targetOrientation = contentOrientation();
m_nextTargetOrientation = Qt::PrimaryOrientation;
- connect(screen(), SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(orientationChanged(Qt::ScreenOrientation)));
- connect(m_animation, SIGNAL(finished()), this, SLOT(rotationDone()));
- connect(this, SIGNAL(rotationChanged(qreal)), this, SLOT(paint()));
+ connect(screen(), &QScreen::orientationChanged, this, &PaintedWindow::orientationChanged);
+ connect(m_animation, &QAbstractAnimation::finished, this, &PaintedWindow::rotationDone);
+ typedef void (PaintedWindow::*PaintedWindowVoidSlot)();
+ connect(this, &PaintedWindow::rotationChanged,
+ this, static_cast<PaintedWindowVoidSlot>(&PaintedWindow::paint));
}
void PaintedWindow::exposeEvent(QExposeEvent *)
diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp
index 22111afdcb..06f35db97a 100644
--- a/examples/opengl/qopenglwidget/mainwindow.cpp
+++ b/examples/opengl/qopenglwidget/mainwindow.cpp
@@ -51,6 +51,8 @@
#include "glwidget.h"
+typedef void (QWidget::*QWidgetVoidSlot)();
+
MainWindow::MainWindow()
: m_nextX(1), m_nextY(1)
{
@@ -107,34 +109,27 @@ MainWindow::MainWindow()
groupBox->setLayout(m_layout);
+
QMenu *fileMenu = menuBar()->addMenu("&File");
+ fileMenu->addAction("E&xit", this, &QWidget::close);
QMenu *showMenu = menuBar()->addMenu("&Show");
- QMenu *helpMenu = menuBar()->addMenu("&Help");
- QAction *exit = new QAction("E&xit", fileMenu);
- QAction *aboutQt = new QAction("About Qt", helpMenu);
- QAction *showLogo = new QAction("Show 3D Logo", showMenu);
- QAction *showTexture = new QAction("Show 2D Texture", showMenu);
- QAction *showBubbles = new QAction("Show bubbles", showMenu);
+ showMenu->addAction("Show 3D Logo", glwidget, &GLWidget::setLogo);
+ showMenu->addAction("Show 2D Texture", glwidget, &GLWidget::setTexture);
+ QAction *showBubbles = showMenu->addAction("Show bubbles", glwidget, &GLWidget::setShowBubbles);
showBubbles->setCheckable(true);
showBubbles->setChecked(true);
- fileMenu->addAction(exit);
- helpMenu->addAction(aboutQt);
- showMenu->addAction(showLogo);
- showMenu->addAction(showTexture);
- showMenu->addAction(showBubbles);
-
- connect(exit, SIGNAL(triggered(bool)), this, SLOT(close()));
- connect(aboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));
+ QMenu *helpMenu = menuBar()->addMenu("&Help");
+ helpMenu->addAction("About Qt", qApp, &QApplication::aboutQt);
- connect(m_timer, SIGNAL(timeout()), glwidget, SLOT(update()));
+ connect(m_timer, &QTimer::timeout,
+ glwidget, static_cast<QWidgetVoidSlot>(&QWidget::update));
- connect(showLogo, SIGNAL(triggered(bool)), glwidget, SLOT(setLogo()));
- connect(showTexture, SIGNAL(triggered(bool)), glwidget, SLOT(setTexture()));
- connect(showBubbles, SIGNAL(triggered(bool)), glwidget, SLOT(setShowBubbles(bool)));
- connect(slider, SIGNAL(valueChanged(int)), glwidget, SLOT(setScaling(int)));
+ connect(slider, &QAbstractSlider::valueChanged, glwidget, &GLWidget::setScaling);
connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent);
- connect(updateInterval, SIGNAL(valueChanged(int)), this, SLOT(updateIntervalChanged(int)));
+ typedef void (QSpinBox::*QSpinBoxIntSignal)(int);
+ connect(updateInterval, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged),
+ this, &MainWindow::updateIntervalChanged);
connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged);
connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled);
@@ -157,7 +152,7 @@ void MainWindow::addNew()
return;
GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256));
m_glWidgets << w;
- connect(m_timer, SIGNAL(timeout()), w, SLOT(update()));
+ connect(m_timer, &QTimer::timeout, w, static_cast<QWidgetVoidSlot>(&QWidget::update));
m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
if (m_nextX == 3) {
m_nextX = 1;
diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp
index 123bebbe2a..f444b5d7c7 100644
--- a/examples/opengl/qopenglwindow/main.cpp
+++ b/examples/opengl/qopenglwindow/main.cpp
@@ -163,16 +163,20 @@ void OpenGLWindow::keyPressEvent(QKeyEvent *e)
void OpenGLWindow::setAnimating(bool enabled)
{
+ typedef void (QPaintDeviceWindow::*QPaintDeviceWindowVoidSlot)();
+
if (enabled) {
// Animate continuously, throttled by the blocking swapBuffers() call the
// QOpenGLWindow internally executes after each paint. Once that is done
// (frameSwapped signal is emitted), we schedule a new update. This
// obviously assumes that the swap interval (see
// QSurfaceFormat::setSwapInterval()) is non-zero.
- connect(this, SIGNAL(frameSwapped()), this, SLOT(update()));
+ connect(this, &QOpenGLWindow::frameSwapped,
+ this, static_cast<QPaintDeviceWindowVoidSlot>(&QPaintDeviceWindow::update));
update();
} else {
- disconnect(this, SIGNAL(frameSwapped()), this, SLOT(update()));
+ disconnect(this, &QOpenGLWindow::frameSwapped,
+ this, static_cast<QPaintDeviceWindowVoidSlot>(&QPaintDeviceWindow::update));
}
}
diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp
index e9ad8e2cc6..fddb9f9945 100644
--- a/examples/opengl/textures/window.cpp
+++ b/examples/opengl/textures/window.cpp
@@ -59,8 +59,8 @@ Window::Window()
glWidgets[i][j]->rotateBy(+42 * 16, +42 * 16, -21 * 16);
mainLayout->addWidget(glWidgets[i][j], i, j);
- connect(glWidgets[i][j], SIGNAL(clicked()),
- this, SLOT(setCurrentGlWidget()));
+ connect(glWidgets[i][j], &GLWidget::clicked,
+ this, &Window::setCurrentGlWidget);
}
}
setLayout(mainLayout);
@@ -68,7 +68,7 @@ Window::Window()
currentGlWidget = glWidgets[0][0];
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep()));
+ connect(timer, &QTimer::timeout, this, &Window::rotateOneStep);
timer->start(20);
setWindowTitle(tr("Textures"));