summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJochen Seemann <seemann.jochen@gmail.com>2017-11-23 21:12:24 +0100
committerJochen Seemann <seemann.jochen@gmail.com>2017-12-19 12:04:34 +0000
commit93630cd621b472d73fc8456ca396cda012a1aee0 (patch)
treebb42ea8fc88d5961493caccbd116c5b1748a089f /examples
parent5629823b05ca7d24924ac879b5a0469a3cb03e78 (diff)
examples: use Qt5-style connects where possible
Additionally, remove obsolete CHECKED_CONNECT macro from the spectrum example. Change-Id: Id6fe01718679463c2b025d688c970583d64d60e9 Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io> Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.cpp26
-rw-r--r--examples/multimedia/audiodecoder/main.cpp3
-rw-r--r--examples/multimedia/declarative-camera/qmlcamera.cpp3
-rw-r--r--examples/multimedia/radio/radio.cpp24
-rw-r--r--examples/multimedia/spectrum/app/engine.cpp28
-rw-r--r--examples/multimedia/spectrum/app/levelmeter.cpp3
-rw-r--r--examples/multimedia/spectrum/app/mainwidget.cpp78
-rw-r--r--examples/multimedia/spectrum/app/settingsdialog.cpp20
-rw-r--r--examples/multimedia/spectrum/app/spectrum.h16
-rw-r--r--examples/multimedia/spectrum/app/spectrumanalyser.cpp4
-rw-r--r--examples/multimedia/spectrum/app/tonegeneratordialog.cpp20
-rw-r--r--examples/multimedia/video/qmlvideo/main.cpp2
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp4
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp12
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp23
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp19
16 files changed, 145 insertions, 140 deletions
diff --git a/examples/multimedia/audiodecoder/audiodecoder.cpp b/examples/multimedia/audiodecoder/audiodecoder.cpp
index 5145d529..86904f7c 100644
--- a/examples/multimedia/audiodecoder/audiodecoder.cpp
+++ b/examples/multimedia/audiodecoder/audiodecoder.cpp
@@ -67,15 +67,23 @@ AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
format.setSampleType(QAudioFormat::SignedInt);
m_decoder.setAudioFormat(format);
- connect(&m_decoder, SIGNAL(bufferReady()), this, SLOT(bufferReady()));
- connect(&m_decoder, SIGNAL(error(QAudioDecoder::Error)), this, SLOT(error(QAudioDecoder::Error)));
- connect(&m_decoder, SIGNAL(stateChanged(QAudioDecoder::State)), this, SLOT(stateChanged(QAudioDecoder::State)));
- connect(&m_decoder, SIGNAL(finished()), this, SLOT(finished()));
- connect(&m_decoder, SIGNAL(positionChanged(qint64)), this, SLOT(updateProgress()));
- connect(&m_decoder, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress()));
-
- connect(&m_soundEffect, SIGNAL(statusChanged()), this, SLOT(playbackStatusChanged()));
- connect(&m_soundEffect, SIGNAL(playingChanged()), this, SLOT(playingChanged()));
+ connect(&m_decoder, &QAudioDecoder::bufferReady,
+ this, &AudioDecoder::bufferReady);
+ connect(&m_decoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error),
+ this, QOverload<QAudioDecoder::Error>::of(&AudioDecoder::error));
+ connect(&m_decoder, &QAudioDecoder::stateChanged,
+ this, &AudioDecoder::stateChanged);
+ connect(&m_decoder, &QAudioDecoder::finished,
+ this, &AudioDecoder::finished);
+ connect(&m_decoder, &QAudioDecoder::positionChanged,
+ this, &AudioDecoder::updateProgress);
+ connect(&m_decoder, &QAudioDecoder::durationChanged,
+ this, &AudioDecoder::updateProgress);
+
+ connect(&m_soundEffect, &QSoundEffect::statusChanged,
+ this, &AudioDecoder::playbackStatusChanged);
+ connect(&m_soundEffect, &QSoundEffect::playingChanged,
+ this, &AudioDecoder::playingChanged);
m_progress = -1.0;
}
diff --git a/examples/multimedia/audiodecoder/main.cpp b/examples/multimedia/audiodecoder/main.cpp
index 2b4b9dab..c0947b83 100644
--- a/examples/multimedia/audiodecoder/main.cpp
+++ b/examples/multimedia/audiodecoder/main.cpp
@@ -95,7 +95,8 @@ int main(int argc, char *argv[])
targetFile.setFile(sourceFile.dir().absoluteFilePath("out.wav"));
AudioDecoder decoder(isPlayback, isDelete);
- QObject::connect(&decoder, SIGNAL(done()), &app, SLOT(quit()));
+ QObject::connect(&decoder, &AudioDecoder::done,
+ &app, &QCoreApplication::quit);
decoder.setSourceFilename(sourceFile.absoluteFilePath());
decoder.setTargetFilename(targetFile.absoluteFilePath());
decoder.start();
diff --git a/examples/multimedia/declarative-camera/qmlcamera.cpp b/examples/multimedia/declarative-camera/qmlcamera.cpp
index 1118e0dc..edffe6bb 100644
--- a/examples/multimedia/declarative-camera/qmlcamera.cpp
+++ b/examples/multimedia/declarative-camera/qmlcamera.cpp
@@ -59,7 +59,8 @@ int main(int argc, char* argv[])
view.setResizeMode(QQuickView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
- QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+ QObject::connect(view.engine(), &QQmlEngine::quit,
+ qApp, &QGuiApplication::quit);
view.setSource(QUrl("qrc:///declarative-camera.qml"));
view.resize(800, 480);
view.show();
diff --git a/examples/multimedia/radio/radio.cpp b/examples/multimedia/radio/radio.cpp
index c6bac969..f4c9f553 100644
--- a/examples/multimedia/radio/radio.cpp
+++ b/examples/multimedia/radio/radio.cpp
@@ -53,7 +53,8 @@
Radio::Radio()
{
radio = new QRadioTuner;
- connect(radio, SIGNAL(error(QRadioTuner::Error)), this, SLOT(error(QRadioTuner::Error)));
+ connect(radio, QOverload<QRadioTuner::Error>::of(&QRadioTuner::error),
+ this, QOverload<QRadioTuner::Error>::of(&Radio::error));
if (radio->isBandSupported(QRadioTuner::FM))
radio->setBand(QRadioTuner::FM);
@@ -68,7 +69,8 @@ Radio::Radio()
freq = new QLabel;
freq->setText(QString("%1 kHz").arg(radio->frequency()/1000));
topBar->addWidget(freq);
- connect(radio, SIGNAL(frequencyChanged(int)), SLOT(freqChanged(int)));
+ connect(radio, &QRadioTuner::frequencyChanged,
+ this, &Radio::freqChanged);
signal = new QLabel;
if (radio->isAvailable())
@@ -76,34 +78,40 @@ Radio::Radio()
else
signal->setText(tr("No radio found"));
topBar->addWidget(signal);
- connect(radio, SIGNAL(signalStrengthChanged(int)), SLOT(signalChanged(int)));
+ connect(radio, &QRadioTuner::signalStrengthChanged,
+ this, &Radio::signalChanged);
volumeSlider = new QSlider(Qt::Vertical,this);
volumeSlider->setRange(0, 100);
volumeSlider->setValue(50);
- connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(updateVolume(int)));
+ connect(volumeSlider, &QSlider::valueChanged,
+ this, &Radio::updateVolume);
topBar->addWidget(volumeSlider);
layout->addLayout(buttonBar);
searchLeft = new QPushButton;
searchLeft->setText(tr("scan Down"));
- connect(searchLeft, SIGNAL(clicked()), SLOT(searchDown()));
+ connect(searchLeft, &QPushButton::clicked,
+ this, &Radio::searchDown);
buttonBar->addWidget(searchLeft);
left = new QPushButton;
left->setText(tr("Freq Down"));
- connect(left, SIGNAL(clicked()), SLOT(freqDown()));
+ connect(left, &QPushButton::clicked,
+ this, &Radio::freqDown);
buttonBar->addWidget(left);
right = new QPushButton;
- connect(right, SIGNAL(clicked()), SLOT(freqUp()));
+ connect(right, &QPushButton::clicked,
+ this, &Radio::freqUp);
right->setText(tr("Freq Up"));
buttonBar->addWidget(right);
searchRight = new QPushButton;
searchRight->setText(tr("scan Up"));
- connect(searchRight, SIGNAL(clicked()), SLOT(searchUp()));
+ connect(searchRight, &QPushButton::clicked,
+ this, &Radio::searchUp);
buttonBar->addWidget(searchRight);
window->setLayout(layout);
diff --git a/examples/multimedia/spectrum/app/engine.cpp b/examples/multimedia/spectrum/app/engine.cpp
index eb289ca6..7e11d012 100644
--- a/examples/multimedia/spectrum/app/engine.cpp
+++ b/examples/multimedia/spectrum/app/engine.cpp
@@ -108,10 +108,8 @@ Engine::Engine(QObject *parent)
{
qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum");
qRegisterMetaType<WindowFunction>("WindowFunction");
- CHECKED_CONNECT(&m_spectrumAnalyser,
- SIGNAL(spectrumChanged(FrequencySpectrum)),
- this,
- SLOT(spectrumChanged(FrequencySpectrum)));
+ connect(&m_spectrumAnalyser, QOverload<const FrequencySpectrum&>::of(&SpectrumAnalyser::spectrumChanged),
+ this, QOverload<const FrequencySpectrum&>::of(&Engine::spectrumChanged));
// This code might misinterpret things like "-something -category". But
// it's unlikely that that needs to be supported so we'll let it go.
@@ -243,16 +241,17 @@ void Engine::startRecording()
setRecordPosition(0, true);
stopPlayback();
m_mode = QAudio::AudioInput;
- CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)),
- this, SLOT(audioStateChanged(QAudio::State)));
- CHECKED_CONNECT(m_audioInput, SIGNAL(notify()),
- this, SLOT(audioNotify()));
+ connect(m_audioInput, &QAudioInput::stateChanged,
+ this, &Engine::audioStateChanged);
+ connect(m_audioInput, &QAudioInput::notify,
+ this, &Engine::audioNotify);
+
m_count = 0;
m_dataLength = 0;
emit dataLengthChanged(0);
m_audioInputIODevice = m_audioInput->start();
- CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()),
- this, SLOT(audioDataReady()));
+ connect(m_audioInputIODevice, &QIODevice::readyRead,
+ this, &Engine::audioDataReady);
}
}
}
@@ -275,10 +274,11 @@ void Engine::startPlayback()
setPlayPosition(0, true);
stopRecording();
m_mode = QAudio::AudioOutput;
- CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)),
- this, SLOT(audioStateChanged(QAudio::State)));
- CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()),
- this, SLOT(audioNotify()));
+ connect(m_audioOutput, &QAudioOutput::stateChanged,
+ this, &Engine::audioStateChanged);
+ connect(m_audioOutput, &QAudioOutput::notify,
+ this, &Engine::audioNotify);
+
m_count = 0;
if (m_file) {
m_file->seek(0);
diff --git a/examples/multimedia/spectrum/app/levelmeter.cpp b/examples/multimedia/spectrum/app/levelmeter.cpp
index a2741d23..1c720905 100644
--- a/examples/multimedia/spectrum/app/levelmeter.cpp
+++ b/examples/multimedia/spectrum/app/levelmeter.cpp
@@ -77,7 +77,8 @@ LevelMeter::LevelMeter(QWidget *parent)
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
setMinimumWidth(30);
- connect(m_redrawTimer, SIGNAL(timeout()), this, SLOT(redrawTimerExpired()));
+ connect(m_redrawTimer, &QTimer::timeout,
+ this, &LevelMeter::redrawTimerExpired);
m_redrawTimer->start(RedrawInterval);
}
diff --git a/examples/multimedia/spectrum/app/mainwidget.cpp b/examples/multimedia/spectrum/app/mainwidget.cpp
index 6585fec9..945313f3 100644
--- a/examples/multimedia/spectrum/app/mainwidget.cpp
+++ b/examples/multimedia/spectrum/app/mainwidget.cpp
@@ -339,62 +339,62 @@ void MainWidget::createUi()
void MainWidget::connectUi()
{
- CHECKED_CONNECT(m_recordButton, SIGNAL(clicked()),
- m_engine, SLOT(startRecording()));
+ connect(m_recordButton, &QPushButton::clicked,
+ m_engine, &Engine::startRecording);
- CHECKED_CONNECT(m_pauseButton, SIGNAL(clicked()),
- m_engine, SLOT(suspend()));
+ connect(m_pauseButton, &QPushButton::clicked,
+ m_engine, &Engine::suspend);
- CHECKED_CONNECT(m_playButton, SIGNAL(clicked()),
- m_engine, SLOT(startPlayback()));
+ connect(m_playButton, &QPushButton::clicked,
+ m_engine, &Engine::startPlayback);
- CHECKED_CONNECT(m_settingsButton, SIGNAL(clicked()),
- this, SLOT(showSettingsDialog()));
+ connect(m_settingsButton, &QPushButton::clicked,
+ this, &MainWidget::showSettingsDialog);
- CHECKED_CONNECT(m_engine, SIGNAL(stateChanged(QAudio::Mode,QAudio::State)),
- this, SLOT(stateChanged(QAudio::Mode,QAudio::State)));
+ connect(m_engine, &Engine::stateChanged,
+ this, &MainWidget::stateChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(formatChanged(const QAudioFormat &)),
- this, SLOT(formatChanged(const QAudioFormat &)));
+ connect(m_engine, &Engine::formatChanged,
+ this, &MainWidget::formatChanged);
m_progressBar->bufferLengthChanged(m_engine->bufferLength());
- CHECKED_CONNECT(m_engine, SIGNAL(bufferLengthChanged(qint64)),
- this, SLOT(bufferLengthChanged(qint64)));
+ connect(m_engine, &Engine::bufferLengthChanged,
+ this, &MainWidget::bufferLengthChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(dataLengthChanged(qint64)),
- this, SLOT(updateButtonStates()));
+ connect(m_engine, &Engine::dataLengthChanged,
+ this, &MainWidget::updateButtonStates);
- CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)),
- m_progressBar, SLOT(recordPositionChanged(qint64)));
+ connect(m_engine, &Engine::recordPositionChanged,
+ m_progressBar, &ProgressBar::recordPositionChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)),
- m_progressBar, SLOT(playPositionChanged(qint64)));
+ connect(m_engine, &Engine::playPositionChanged,
+ m_progressBar, &ProgressBar::playPositionChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)),
- this, SLOT(audioPositionChanged(qint64)));
+ connect(m_engine, &Engine::recordPositionChanged,
+ this, &MainWidget::audioPositionChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)),
- this, SLOT(audioPositionChanged(qint64)));
+ connect(m_engine, &Engine::playPositionChanged,
+ this, &MainWidget::audioPositionChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(levelChanged(qreal, qreal, int)),
- m_levelMeter, SLOT(levelChanged(qreal, qreal, int)));
+ connect(m_engine, &Engine::levelChanged,
+ m_levelMeter, &LevelMeter::levelChanged);
- CHECKED_CONNECT(m_engine, SIGNAL(spectrumChanged(qint64, qint64, const FrequencySpectrum &)),
- this, SLOT(spectrumChanged(qint64, qint64, const FrequencySpectrum &)));
+ connect(m_engine, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&Engine::spectrumChanged),
+ this, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&MainWidget::spectrumChanged));
- CHECKED_CONNECT(m_engine, SIGNAL(infoMessage(QString, int)),
- this, SLOT(infoMessage(QString, int)));
+ connect(m_engine, &Engine::infoMessage,
+ this, &MainWidget::infoMessage);
- CHECKED_CONNECT(m_engine, SIGNAL(errorMessage(QString, QString)),
- this, SLOT(errorMessage(QString, QString)));
+ connect(m_engine, &Engine::errorMessage,
+ this, &MainWidget::errorMessage);
- CHECKED_CONNECT(m_spectrograph, SIGNAL(infoMessage(QString, int)),
- this, SLOT(infoMessage(QString, int)));
+ connect(m_spectrograph, &Spectrograph::infoMessage,
+ this, &MainWidget::infoMessage);
#ifndef DISABLE_WAVEFORM
- CHECKED_CONNECT(m_engine, SIGNAL(bufferChanged(qint64, qint64, const QByteArray &)),
- m_waveform, SLOT(bufferChanged(qint64, qint64, const QByteArray &)));
+ connect(m_engine, &Engine::bufferChanged,
+ m_waveform, &Waveform::bufferChanged);
#endif
}
@@ -410,9 +410,9 @@ void MainWidget::createMenus()
m_generateToneAction->setCheckable(true);
m_recordAction->setCheckable(true);
- connect(m_loadFileAction, SIGNAL(triggered(bool)), this, SLOT(showFileDialog()));
- connect(m_generateToneAction, SIGNAL(triggered(bool)), this, SLOT(showToneGeneratorDialog()));
- connect(m_recordAction, SIGNAL(triggered(bool)), this, SLOT(initializeRecord()));
+ connect(m_loadFileAction, &QAction::triggered, this, &MainWidget::showFileDialog);
+ connect(m_generateToneAction, &QAction::triggered, this, &MainWidget::showToneGeneratorDialog);
+ connect(m_recordAction, &QAction::triggered, this, &MainWidget::initializeRecord);
}
void MainWidget::updateButtonStates()
diff --git a/examples/multimedia/spectrum/app/settingsdialog.cpp b/examples/multimedia/spectrum/app/settingsdialog.cpp
index 109817cd..f1723077 100644
--- a/examples/multimedia/spectrum/app/settingsdialog.cpp
+++ b/examples/multimedia/spectrum/app/settingsdialog.cpp
@@ -114,12 +114,12 @@ SettingsDialog::SettingsDialog(
windowFunctionLayout.take(); // ownership transferred to dialogLayout
// Connect
- CHECKED_CONNECT(m_inputDeviceComboBox, SIGNAL(activated(int)),
- this, SLOT(inputDeviceChanged(int)));
- CHECKED_CONNECT(m_outputDeviceComboBox, SIGNAL(activated(int)),
- this, SLOT(outputDeviceChanged(int)));
- CHECKED_CONNECT(m_windowFunctionComboBox, SIGNAL(activated(int)),
- this, SLOT(windowFunctionChanged(int)));
+ connect(m_inputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &SettingsDialog::inputDeviceChanged);
+ connect(m_outputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &SettingsDialog::outputDeviceChanged);
+ connect(m_windowFunctionComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &SettingsDialog::windowFunctionChanged);
// Add standard buttons to layout
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
@@ -127,10 +127,10 @@ SettingsDialog::SettingsDialog(
dialogLayout->addWidget(buttonBox);
// Connect standard buttons
- CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
- this, SLOT(accept()));
- CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
- this, SLOT(reject()));
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
+ this, &SettingsDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
+ this, &SettingsDialog::reject);
setLayout(dialogLayout);
}
diff --git a/examples/multimedia/spectrum/app/spectrum.h b/examples/multimedia/spectrum/app/spectrum.h
index 1d0eedef..aea9ce7c 100644
--- a/examples/multimedia/spectrum/app/spectrum.h
+++ b/examples/multimedia/spectrum/app/spectrum.h
@@ -130,22 +130,6 @@ struct SweptTone
qreal amplitude;
};
-
-//-----------------------------------------------------------------------------
-// Macros
-//-----------------------------------------------------------------------------
-
-// Macro which connects a signal to a slot, and which causes application to
-// abort if the connection fails. This is intended to catch programming errors
-// such as mis-typing a signal or slot name. It is necessary to write our own
-// macro to do this - the following idiom
-// Q_ASSERT(connect(source, signal, receiver, slot));
-// will not work because Q_ASSERT compiles to a no-op in release builds.
-
-#define CHECKED_CONNECT(source, signal, receiver, slot) \
- if (!connect(source, signal, receiver, slot)) \
- qt_assert_x(Q_FUNC_INFO, "CHECKED_CONNECT failed", __FILE__, __LINE__);
-
// Handle some dependencies between macros defined in the .pro file
#ifdef DISABLE_WAVEFORM
diff --git a/examples/multimedia/spectrum/app/spectrumanalyser.cpp b/examples/multimedia/spectrum/app/spectrumanalyser.cpp
index 466c6718..ee024147 100644
--- a/examples/multimedia/spectrum/app/spectrumanalyser.cpp
+++ b/examples/multimedia/spectrum/app/spectrumanalyser.cpp
@@ -172,8 +172,8 @@ SpectrumAnalyser::SpectrumAnalyser(QObject *parent)
, m_count(0)
#endif
{
- CHECKED_CONNECT(m_thread, SIGNAL(calculationComplete(FrequencySpectrum)),
- this, SLOT(calculationComplete(FrequencySpectrum)));
+ connect(m_thread, &SpectrumAnalyserThread::calculationComplete,
+ this, &SpectrumAnalyser::calculationComplete);
}
SpectrumAnalyser::~SpectrumAnalyser()
diff --git a/examples/multimedia/spectrum/app/tonegeneratordialog.cpp b/examples/multimedia/spectrum/app/tonegeneratordialog.cpp
index 55f99841..76fe5d2e 100644
--- a/examples/multimedia/spectrum/app/tonegeneratordialog.cpp
+++ b/examples/multimedia/spectrum/app/tonegeneratordialog.cpp
@@ -106,12 +106,12 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
dialogLayout->addWidget(m_toneGeneratorControl);
// Connect
- CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)),
- this, SLOT(frequencySweepEnabled(bool)));
- CHECKED_CONNECT(m_frequencySlider, SIGNAL(valueChanged(int)),
- m_frequencySpinBox, SLOT(setValue(int)));
- CHECKED_CONNECT(m_frequencySpinBox, SIGNAL(valueChanged(int)),
- m_frequencySlider, SLOT(setValue(int)));
+ connect(m_toneGeneratorSweepCheckBox, &QCheckBox::toggled,
+ this, &ToneGeneratorDialog::frequencySweepEnabled);
+ connect(m_frequencySlider, &QSlider::valueChanged,
+ m_frequencySpinBox, &QSpinBox::setValue);
+ connect(m_frequencySpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ m_frequencySlider, &QSlider::setValue);
// Add standard buttons to layout
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
@@ -119,10 +119,10 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
dialogLayout->addWidget(buttonBox);
// Connect standard buttons
- CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
- this, SLOT(accept()));
- CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
- this, SLOT(reject()));
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
+ this, &ToneGeneratorDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
+ this, &ToneGeneratorDialog::reject);
setLayout(dialogLayout);
}
diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp
index a09ea534..e288c0ae 100644
--- a/examples/multimedia/video/qmlvideo/main.cpp
+++ b/examples/multimedia/video/qmlvideo/main.cpp
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
QQuickView viewer;
viewer.setSource(QUrl("qrc:///qml/qmlvideo/main.qml"));
- QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close()));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QQuickView::close);
QQuickItem *rootObject = viewer.rootObject();
rootObject->setProperty("source1", url1);
diff --git a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp
index 33cead8e..27102b0c 100644
--- a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ b/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -90,7 +90,7 @@ QmlApplicationViewer::QmlApplicationViewer(QWindow *parent)
: QQuickView(parent)
, d(new QmlApplicationViewerPrivate(this))
{
- connect(engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
+ connect(engine(), &QQmlEngine::quit, QCoreApplication::instance(), &QCoreApplication::quit);
setResizeMode(QQuickView::SizeRootObjectToView);
}
@@ -98,7 +98,7 @@ QmlApplicationViewer::QmlApplicationViewer(QQuickView *view, QWindow *parent)
: QQuickView(parent)
, d(new QmlApplicationViewerPrivate(view))
{
- connect(view->engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
+ connect(view->engine(), &QQmlEngine::quit, QCoreApplication::instance(), &QCoreApplication::quit);
view->setResizeMode(QQuickView::SizeRootObjectToView);
}
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
index fb31c7b1..d611497f 100644
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
+++ b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
@@ -105,18 +105,18 @@ FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent)
, m_stalledTimer(new QTimer(this))
{
m_instantaneousElapsed.start();
- connect(m_averageTimer, SIGNAL(timeout()),
- this, SLOT(calculateAverageFrequency()));
+ connect(m_averageTimer, &QTimer::timeout,
+ this, &FrequencyMonitorPrivate::calculateAverageFrequency);
if (DefaultSamplingInterval)
m_averageTimer->start(DefaultSamplingInterval);
m_averageElapsed.start();
- connect(m_traceTimer, SIGNAL(timeout()),
- q_ptr, SLOT(trace()));
+ connect(m_traceTimer, &QTimer::timeout,
+ q_ptr, &FrequencyMonitor::trace);
if (DefaultTraceInterval)
m_traceTimer->start(DefaultTraceInterval);
m_stalledTimer->setSingleShot(true);
- connect(m_stalledTimer, SIGNAL(timeout()),
- this, SLOT(stalled()));
+ connect(m_stalledTimer, &QTimer::timeout,
+ this, &FrequencyMonitorPrivate::stalled);
}
void FrequencyMonitorPrivate::calculateInstantaneousFrequency()
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
index 7da566a2..60b93a11 100644
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
+++ b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
@@ -80,24 +80,25 @@ VideoPlayer::VideoPlayer(QWidget *parent)
rotateSlider->setRange(-180, 180);
rotateSlider->setValue(0);
- connect(rotateSlider, SIGNAL(valueChanged(int)),
- this, SLOT(rotateVideo(int)));
+ connect(rotateSlider, &QSlider::valueChanged,
+ this, &VideoPlayer::rotateVideo);
QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
+ connect(openButton, &QAbstractButton::clicked,
+ this, &VideoPlayer::openFile);
playButton = new QPushButton;
playButton->setEnabled(false);
playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- connect(playButton, SIGNAL(clicked()),
- this, SLOT(play()));
+ connect(playButton, &QAbstractButton::clicked,
+ this, &VideoPlayer::play);
positionSlider = new QSlider(Qt::Horizontal);
positionSlider->setRange(0, 0);
- connect(positionSlider, SIGNAL(sliderMoved(int)),
- this, SLOT(setPosition(int)));
+ connect(positionSlider, &QSlider::sliderMoved,
+ this, &VideoPlayer::setPosition);
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setMargin(0);
@@ -113,10 +114,10 @@ VideoPlayer::VideoPlayer(QWidget *parent)
setLayout(layout);
mediaPlayer.setVideoOutput(videoItem);
- connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),
- this, SLOT(mediaStateChanged(QMediaPlayer::State)));
- connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
- connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
+ connect(&mediaPlayer, &QMediaPlayer::stateChanged,
+ this, &VideoPlayer::mediaStateChanged);
+ connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
+ connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
}
VideoPlayer::~VideoPlayer()
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
index 7d0759c3..7730f814 100644
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
+++ b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
@@ -64,20 +64,21 @@ VideoPlayer::VideoPlayer(QWidget *parent)
VideoWidget *videoWidget = new VideoWidget;
QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
+ connect(openButton, &QAbstractButton::clicked,
+ this, &VideoPlayer::openFile);
playButton = new QPushButton;
playButton->setEnabled(false);
playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- connect(playButton, SIGNAL(clicked()),
- this, SLOT(play()));
+ connect(playButton, &QAbstractButton::clicked,
+ this, &VideoPlayer::play);
positionSlider = new QSlider(Qt::Horizontal);
positionSlider->setRange(0, 0);
- connect(positionSlider, SIGNAL(sliderMoved(int)),
- this, SLOT(setPosition(int)));
+ connect(positionSlider, &QSlider::sliderMoved,
+ this, &VideoPlayer::setPosition);
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setMargin(0);
@@ -92,10 +93,10 @@ VideoPlayer::VideoPlayer(QWidget *parent)
setLayout(layout);
mediaPlayer.setVideoOutput(videoWidget->videoSurface());
- connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),
- this, SLOT(mediaStateChanged(QMediaPlayer::State)));
- connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
- connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
+ connect(&mediaPlayer, &QMediaPlayer::stateChanged,
+ this, &VideoPlayer::mediaStateChanged);
+ connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
+ connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
}
VideoPlayer::~VideoPlayer()