summaryrefslogtreecommitdiffstats
path: root/examples/opengl/qopenglwidget/mainwindow.cpp
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 /examples/opengl/qopenglwidget/mainwindow.cpp
parent4b340402b97b83790b3d71a8244a246eec4f8abd (diff)
Port examples/opengl to new connection syntax.
Change-Id: I486a4a2326bf57ec5ea08bccdcef79c3e5553db5 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'examples/opengl/qopenglwidget/mainwindow.cpp')
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.cpp37
1 files changed, 16 insertions, 21 deletions
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;