summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-02 14:16:47 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-01-26 10:37:06 +0000
commitbf4bf3a58360d4f7907895096b452cb3821ea593 (patch)
tree0a784f40986afb9c73aed2f5d13a2f554a09ce2e /examples/widgets/widgets
parente81acde7d0cf5fb44a3fb2cf0bf7aaa2c65f807e (diff)
Cleanup Widgets examples - signals/slots
Cleanup the widgets examples - use new signal/slot syntax where possible Change-Id: I6bc8953534d8b1efca0de4ee6a9fe4a6aa79fda9 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/analogclock/analogclock.cpp2
-rw-r--r--examples/widgets/widgets/calendarwidget/window.cpp76
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.cpp6
-rw-r--r--examples/widgets/widgets/lineedits/window.cpp20
-rw-r--r--examples/widgets/widgets/mousebuttons/main.cpp2
-rw-r--r--examples/widgets/widgets/movie/movieplayer.cpp23
-rw-r--r--examples/widgets/widgets/scribble/mainwindow.cpp20
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.cpp4
-rw-r--r--examples/widgets/widgets/sliders/slidersgroup.cpp8
-rw-r--r--examples/widgets/widgets/sliders/window.cpp48
-rw-r--r--examples/widgets/widgets/spinboxes/window.cpp8
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.cpp26
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.cpp4
-rw-r--r--examples/widgets/widgets/validators/ledwidget.cpp2
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp3
-rw-r--r--examples/widgets/widgets/windowflags/controllerwindow.cpp9
-rw-r--r--examples/widgets/widgets/windowflags/previewwindow.cpp3
17 files changed, 134 insertions, 130 deletions
diff --git a/examples/widgets/widgets/analogclock/analogclock.cpp b/examples/widgets/widgets/analogclock/analogclock.cpp
index 0dc2fbc708..bee316b9b7 100644
--- a/examples/widgets/widgets/analogclock/analogclock.cpp
+++ b/examples/widgets/widgets/analogclock/analogclock.cpp
@@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent)
//! [3] //! [4]
QTimer *timer = new QTimer(this);
//! [4] //! [5]
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+ connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update));
//! [5] //! [6]
timer->start(1000);
//! [6]
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp
index a1c1746786..64047aaac9 100644
--- a/examples/widgets/widgets/calendarwidget/window.cpp
+++ b/examples/widgets/widgets/calendarwidget/window.cpp
@@ -221,8 +221,8 @@ void Window::createPreviewGroupBox()
calendar->setMaximumDate(QDate(3000, 1, 1));
calendar->setGridVisible(true);
- connect(calendar, SIGNAL(currentPageChanged(int,int)),
- this, SLOT(reformatCalendarPage()));
+ connect(calendar, &QCalendarWidget::currentPageChanged,
+ this, &Window::reformatCalendarPage);
previewLayout = new QGridLayout;
previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter);
@@ -306,20 +306,20 @@ void Window::createGeneralOptionsGroupBox()
verticalHeaderLabel->setBuddy(verticalHeaderCombo);
//! [11]
- connect(localeCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(localeChanged(int)));
- connect(firstDayCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(firstDayChanged(int)));
- connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(selectionModeChanged(int)));
- connect(gridCheckBox, SIGNAL(toggled(bool)),
- calendar, SLOT(setGridVisible(bool)));
- connect(navigationCheckBox, SIGNAL(toggled(bool)),
- calendar, SLOT(setNavigationBarVisible(bool)));
- connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(horizontalHeaderChanged(int)));
- connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(verticalHeaderChanged(int)));
+ connect(localeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::localeChanged);
+ connect(firstDayCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::firstDayChanged);
+ connect(selectionModeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::selectionModeChanged);
+ connect(gridCheckBox, &QCheckBox::toggled,
+ calendar, &QCalendarWidget::setGridVisible);
+ connect(navigationCheckBox, &QCheckBox::toggled,
+ calendar, &QCalendarWidget::setNavigationBarVisible);
+ connect(horizontalHeaderCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::horizontalHeaderChanged);
+ connect(verticalHeaderCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::verticalHeaderChanged);
//! [11]
QHBoxLayout *checkBoxLayout = new QHBoxLayout;
@@ -382,14 +382,14 @@ void Window::createDatesGroupBox()
maximumDateLabel->setBuddy(maximumDateEdit);
//! [13] //! [14]
- connect(currentDateEdit, SIGNAL(dateChanged(QDate)),
- calendar, SLOT(setSelectedDate(QDate)));
- connect(calendar, SIGNAL(selectionChanged()),
- this, SLOT(selectedDateChanged()));
- connect(minimumDateEdit, SIGNAL(dateChanged(QDate)),
- this, SLOT(minimumDateChanged(QDate)));
- connect(maximumDateEdit, SIGNAL(dateChanged(QDate)),
- this, SLOT(maximumDateChanged(QDate)));
+ connect(currentDateEdit, &QDateEdit::dateChanged,
+ calendar, &QCalendarWidget::setSelectedDate);
+ connect(calendar, &QCalendarWidget::selectionChanged,
+ this, &Window::selectedDateChanged);
+ connect(minimumDateEdit, &QDateEdit::dateChanged,
+ this, &Window::minimumDateChanged);
+ connect(maximumDateEdit, &QDateEdit::dateChanged,
+ this, &Window::maximumDateChanged);
//! [14]
QGridLayout *dateBoxLayout = new QGridLayout;
@@ -439,20 +439,20 @@ void Window::createTextFormatsGroupBox()
mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));
//! [17] //! [18]
- connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(weekdayFormatChanged()));
- connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(reformatCalendarPage()));
- connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(weekendFormatChanged()));
- connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(reformatCalendarPage()));
- connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)),
- this, SLOT(reformatHeaders()));
- connect(firstFridayCheckBox, SIGNAL(toggled(bool)),
- this, SLOT(reformatCalendarPage()));
- connect(mayFirstCheckBox, SIGNAL(toggled(bool)),
- this, SLOT(reformatCalendarPage()));
+ connect(weekdayColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::weekdayFormatChanged);
+ connect(weekdayColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::reformatCalendarPage);
+ connect(weekendColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::weekendFormatChanged);
+ connect(weekendColorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::reformatCalendarPage);
+ connect(headerTextFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &Window::reformatHeaders);
+ connect(firstFridayCheckBox, &QCheckBox::toggled,
+ this, &Window::reformatCalendarPage);
+ connect(mayFirstCheckBox, &QCheckBox::toggled,
+ this, &Window::reformatCalendarPage);
//! [18]
QHBoxLayout *checkBoxLayout = new QHBoxLayout;
diff --git a/examples/widgets/widgets/codeeditor/codeeditor.cpp b/examples/widgets/widgets/codeeditor/codeeditor.cpp
index 7e56a75294..8e29860669 100644
--- a/examples/widgets/widgets/codeeditor/codeeditor.cpp
+++ b/examples/widgets/widgets/codeeditor/codeeditor.cpp
@@ -58,9 +58,9 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
lineNumberArea = new LineNumberArea(this);
- connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
- connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
- connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
+ connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth);
+ connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea);
+ connect(this, &CodeEditor::cursorPositionChanged, this, &CodeEditor::highlightCurrentLine);
updateLineNumberAreaWidth(0);
highlightCurrentLine();
diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp
index 0926f6f20b..33f09d544d 100644
--- a/examples/widgets/widgets/lineedits/window.cpp
+++ b/examples/widgets/widgets/lineedits/window.cpp
@@ -123,16 +123,16 @@ Window::Window(QWidget *parent)
//! [4]
//! [5]
- connect(echoComboBox, SIGNAL(activated(int)),
- this, SLOT(echoChanged(int)));
- connect(validatorComboBox, SIGNAL(activated(int)),
- this, SLOT(validatorChanged(int)));
- connect(alignmentComboBox, SIGNAL(activated(int)),
- this, SLOT(alignmentChanged(int)));
- connect(inputMaskComboBox, SIGNAL(activated(int)),
- this, SLOT(inputMaskChanged(int)));
- connect(accessComboBox, SIGNAL(activated(int)),
- this, SLOT(accessChanged(int)));
+ connect(echoComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::echoChanged);
+ connect(validatorComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::validatorChanged);
+ connect(alignmentComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::alignmentChanged);
+ connect(inputMaskComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::inputMaskChanged);
+ connect(accessComboBox, QOverload<int>::of(&QComboBox::activated),
+ this, &Window::accessChanged);
//! [5]
//! [6]
diff --git a/examples/widgets/widgets/mousebuttons/main.cpp b/examples/widgets/widgets/mousebuttons/main.cpp
index 28be0ffddf..e35a442181 100644
--- a/examples/widgets/widgets/mousebuttons/main.cpp
+++ b/examples/widgets/widgets/mousebuttons/main.cpp
@@ -68,7 +68,7 @@ int main(int argv, char **args)
testArea->setText("To test your mouse with Qt, press buttons in this area.\nYou may also scroll or tilt your mouse wheel.");
QPushButton *quitButton = new QPushButton("Quit");
- QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+ QObject::connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(testArea);
diff --git a/examples/widgets/widgets/movie/movieplayer.cpp b/examples/widgets/widgets/movie/movieplayer.cpp
index 61e85537a3..3003bfb541 100644
--- a/examples/widgets/widgets/movie/movieplayer.cpp
+++ b/examples/widgets/widgets/movie/movieplayer.cpp
@@ -69,13 +69,12 @@ MoviePlayer::MoviePlayer(QWidget *parent)
createControls();
createButtons();
- connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider()));
- connect(movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SLOT(updateButtons()));
- connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow()));
- connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int)));
- connect(speedSpinBox, SIGNAL(valueChanged(int)),
- movie, SLOT(setSpeed(int)));
+ connect(movie, &QMovie::frameChanged, this, &MoviePlayer::updateFrameSlider);
+ connect(movie, &QMovie::stateChanged, this, &MoviePlayer::updateButtons);
+ connect(fitCheckBox, &QCheckBox::clicked, this, &MoviePlayer::fitToWindow);
+ connect(frameSlider, &QSlider::valueChanged, this, &MoviePlayer::goToFrame);
+ connect(speedSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ movie, &QMovie::setSpeed);
mainLayout = new QVBoxLayout;
mainLayout->addWidget(movieLabel);
@@ -182,32 +181,32 @@ void MoviePlayer::createButtons()
openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
openButton->setIconSize(iconSize);
openButton->setToolTip(tr("Open File"));
- connect(openButton, SIGNAL(clicked()), this, SLOT(open()));
+ connect(openButton, &QToolButton::clicked, this, &MoviePlayer::open);
playButton = new QToolButton;
playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
playButton->setIconSize(iconSize);
playButton->setToolTip(tr("Play"));
- connect(playButton, SIGNAL(clicked()), movie, SLOT(start()));
+ connect(playButton, &QToolButton::clicked, movie, &QMovie::start);
pauseButton = new QToolButton;
pauseButton->setCheckable(true);
pauseButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
pauseButton->setIconSize(iconSize);
pauseButton->setToolTip(tr("Pause"));
- connect(pauseButton, SIGNAL(clicked(bool)), movie, SLOT(setPaused(bool)));
+ connect(pauseButton, &QToolButton::clicked, movie, &QMovie::setPaused);
stopButton = new QToolButton;
stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
stopButton->setIconSize(iconSize);
stopButton->setToolTip(tr("Stop"));
- connect(stopButton, SIGNAL(clicked()), movie, SLOT(stop()));
+ connect(stopButton, &QToolButton::clicked, movie, &QMovie::stop);
quitButton = new QToolButton;
quitButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
quitButton->setIconSize(iconSize);
quitButton->setToolTip(tr("Quit"));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(quitButton, &QToolButton::clicked, this, &MoviePlayer::close);
buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp
index b8d01d505c..58dc42c076 100644
--- a/examples/widgets/widgets/scribble/mainwindow.cpp
+++ b/examples/widgets/widgets/scribble/mainwindow.cpp
@@ -151,40 +151,40 @@ void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+ connect(openAct, &QAction::triggered, this, &MainWindow::open);
foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
QString text = tr("%1...").arg(QString(format).toUpper());
QAction *action = new QAction(text, this);
action->setData(format);
- connect(action, SIGNAL(triggered()), this, SLOT(save()));
+ connect(action, &QAction::triggered, this, &MainWindow::save);
saveAsActs.append(action);
}
printAct = new QAction(tr("&Print..."), this);
- connect(printAct, SIGNAL(triggered()), scribbleArea, SLOT(print()));
+ connect(printAct, &QAction::triggered, scribbleArea, &ScribbleArea::print);
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+ connect(exitAct, &QAction::triggered, this, &MainWindow::close);
penColorAct = new QAction(tr("&Pen Color..."), this);
- connect(penColorAct, SIGNAL(triggered()), this, SLOT(penColor()));
+ connect(penColorAct, &QAction::triggered, this, &MainWindow::penColor);
penWidthAct = new QAction(tr("Pen &Width..."), this);
- connect(penWidthAct, SIGNAL(triggered()), this, SLOT(penWidth()));
+ connect(penWidthAct, &QAction::triggered, this, &MainWindow::penWidth);
clearScreenAct = new QAction(tr("&Clear Screen"), this);
clearScreenAct->setShortcut(tr("Ctrl+L"));
- connect(clearScreenAct, SIGNAL(triggered()),
- scribbleArea, SLOT(clearImage()));
+ connect(clearScreenAct, &QAction::triggered,
+ scribbleArea, &ScribbleArea::clearImage);
aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+ connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
}
//! [14]
diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp
index af0cd01be5..8e7d831938 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.cpp
+++ b/examples/widgets/widgets/shapedclock/shapedclock.cpp
@@ -57,12 +57,12 @@ ShapedClock::ShapedClock(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)
{
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+ connect(timer, &QTimer::timeout, this, QOverload<>::of(&ShapedClock::update));
timer->start(1000);
QAction *quitAction = new QAction(tr("E&xit"), this);
quitAction->setShortcut(tr("Ctrl+Q"));
- connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
addAction(quitAction);
setContextMenuPolicy(Qt::ActionsContextMenu);
diff --git a/examples/widgets/widgets/sliders/slidersgroup.cpp b/examples/widgets/widgets/sliders/slidersgroup.cpp
index 365a003047..3bccdd687a 100644
--- a/examples/widgets/widgets/sliders/slidersgroup.cpp
+++ b/examples/widgets/widgets/sliders/slidersgroup.cpp
@@ -69,11 +69,11 @@ SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title,
dial = new QDial;
dial->setFocusPolicy(Qt::StrongFocus);
- connect(slider, SIGNAL(valueChanged(int)), scrollBar, SLOT(setValue(int)));
- connect(scrollBar, SIGNAL(valueChanged(int)), dial, SLOT(setValue(int)));
- connect(dial, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
+ connect(slider, &QSlider::valueChanged, scrollBar, &QScrollBar::setValue);
+ connect(scrollBar, &QScrollBar::valueChanged, dial, &QDial::setValue);
+ connect(dial, &QDial::valueChanged, slider, &QSlider::setValue);
//! [0] //! [1]
- connect(dial, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
+ connect(dial, &QDial::valueChanged, this, &SlidersGroup::valueChanged);
//! [1] //! [2]
//! [2] //! [3]
diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp
index 16467e71be..d73fafec10 100644
--- a/examples/widgets/widgets/sliders/window.cpp
+++ b/examples/widgets/widgets/sliders/window.cpp
@@ -68,13 +68,13 @@ Window::Window(QWidget *parent)
//! [0]
//! [1]
- connect(horizontalSliders, SIGNAL(valueChanged(int)),
+ connect(horizontalSliders, &SlidersGroup::valueChanged,
//! [1] //! [2]
- verticalSliders, SLOT(setValue(int)));
- connect(verticalSliders, SIGNAL(valueChanged(int)),
- valueSpinBox, SLOT(setValue(int)));
- connect(valueSpinBox, SIGNAL(valueChanged(int)),
- horizontalSliders, SLOT(setValue(int)));
+ verticalSliders, &SlidersGroup::setValue);
+ connect(verticalSliders, &SlidersGroup::valueChanged,
+ valueSpinBox, &QSpinBox::setValue);
+ connect(valueSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ horizontalSliders, &SlidersGroup::setValue);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(controlsGroup);
@@ -121,25 +121,25 @@ void Window::createControls(const QString &title)
orientationCombo->addItem(tr("Vertical slider-like widgets"));
//! [6] //! [7]
- connect(orientationCombo, SIGNAL(activated(int)),
+ connect(orientationCombo, QOverload<int>::of(&QComboBox::activated),
//! [7] //! [8]
- stackedWidget, SLOT(setCurrentIndex(int)));
- connect(minimumSpinBox, SIGNAL(valueChanged(int)),
- horizontalSliders, SLOT(setMinimum(int)));
- connect(minimumSpinBox, SIGNAL(valueChanged(int)),
- verticalSliders, SLOT(setMinimum(int)));
- connect(maximumSpinBox, SIGNAL(valueChanged(int)),
- horizontalSliders, SLOT(setMaximum(int)));
- connect(maximumSpinBox, SIGNAL(valueChanged(int)),
- verticalSliders, SLOT(setMaximum(int)));
- connect(invertedAppearance, SIGNAL(toggled(bool)),
- horizontalSliders, SLOT(invertAppearance(bool)));
- connect(invertedAppearance, SIGNAL(toggled(bool)),
- verticalSliders, SLOT(invertAppearance(bool)));
- connect(invertedKeyBindings, SIGNAL(toggled(bool)),
- horizontalSliders, SLOT(invertKeyBindings(bool)));
- connect(invertedKeyBindings, SIGNAL(toggled(bool)),
- verticalSliders, SLOT(invertKeyBindings(bool)));
+ stackedWidget, &QStackedWidget::setCurrentIndex);
+ connect(minimumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ horizontalSliders, &SlidersGroup::setMinimum);
+ connect(minimumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ verticalSliders, &SlidersGroup::setMinimum);
+ connect(maximumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ horizontalSliders, &SlidersGroup::setMaximum);
+ connect(maximumSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
+ verticalSliders, &SlidersGroup::setMaximum);
+ connect(invertedAppearance, &QCheckBox::toggled,
+ horizontalSliders, &SlidersGroup::invertAppearance);
+ connect(invertedAppearance, &QCheckBox::toggled,
+ verticalSliders, &SlidersGroup::invertAppearance);
+ connect(invertedKeyBindings, &QCheckBox::toggled,
+ horizontalSliders, &SlidersGroup::invertKeyBindings);
+ connect(invertedKeyBindings, &QCheckBox::toggled,
+ verticalSliders, &SlidersGroup::invertKeyBindings);
QGridLayout *controlsLayout = new QGridLayout;
controlsLayout->addWidget(minimumLabel, 0, 0);
diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp
index eb660faace..fd7c5b527e 100644
--- a/examples/widgets/widgets/spinboxes/window.cpp
+++ b/examples/widgets/widgets/spinboxes/window.cpp
@@ -176,8 +176,8 @@ void Window::createDateTimeEdits()
formatComboBox->addItem("hh:mm ap");
//! [9] //! [10]
- connect(formatComboBox, SIGNAL(activated(QString)),
- this, SLOT(setFormatString(QString)));
+ connect(formatComboBox, QOverload<const QString &>::of(&QComboBox::activated),
+ this, &Window::setFormatString);
//! [10]
setFormatString(formatComboBox->currentText());
@@ -256,9 +256,9 @@ void Window::createDoubleSpinBoxes()
priceSpinBox->setPrefix("$");
priceSpinBox->setValue(99.99);
- connect(precisionSpinBox, SIGNAL(valueChanged(int)),
+ connect(precisionSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
//! [17]
- this, SLOT(changePrecision(int)));
+ this, &Window::changePrecision);
groupSeparatorSpinBox_d = new QDoubleSpinBox;
groupSeparatorSpinBox_d->setRange(-99999999, 99999999);
diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp
index d44547d905..dbe82c547b 100644
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ b/examples/widgets/widgets/styles/widgetgallery.cpp
@@ -79,19 +79,19 @@ WidgetGallery::WidgetGallery(QWidget *parent)
//! [0]
//! [1]
- connect(styleComboBox, SIGNAL(activated(QString)),
+ connect(styleComboBox, QOverload<const QString &>::of(&QComboBox::activated),
//! [1] //! [2]
- this, SLOT(changeStyle(QString)));
- connect(useStylePaletteCheckBox, SIGNAL(toggled(bool)),
- this, SLOT(changePalette()));
- connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
- topLeftGroupBox, SLOT(setDisabled(bool)));
- connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
- topRightGroupBox, SLOT(setDisabled(bool)));
- connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
- bottomLeftTabWidget, SLOT(setDisabled(bool)));
- connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
- bottomRightGroupBox, SLOT(setDisabled(bool)));
+ this, &WidgetGallery::changeStyle);
+ connect(useStylePaletteCheckBox, &QCheckBox::toggled,
+ this, &WidgetGallery::changePalette);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ topLeftGroupBox, &QGroupBox::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ topRightGroupBox, &QGroupBox::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ bottomLeftTabWidget, &QGroupBox::setDisabled);
+ connect(disableWidgetsCheckBox, &QCheckBox::toggled,
+ bottomRightGroupBox, &QGroupBox::setDisabled);
//! [2]
//! [3]
@@ -279,7 +279,7 @@ void WidgetGallery::createProgressBar()
progressBar->setValue(0);
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(advanceProgressBar()));
+ connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar);
timer->start(1000);
}
//! [13]
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp
index eb4b3a2424..f187c007dd 100644
--- a/examples/widgets/widgets/stylesheet/mainwindow.cpp
+++ b/examples/widgets/widgets/stylesheet/mainwindow.cpp
@@ -64,8 +64,8 @@ MainWindow::MainWindow(QWidget *parent)
statusBar()->addWidget(new QLabel(tr("Ready")));
- connect(ui.exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
- connect(ui.aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(ui.exitAction, &QAction::triggered, qApp, &QApplication::quit);
+ connect(ui.aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
}
void MainWindow::on_editStyleAction_triggered()
diff --git a/examples/widgets/widgets/validators/ledwidget.cpp b/examples/widgets/widgets/validators/ledwidget.cpp
index 65248741b5..462f416c86 100644
--- a/examples/widgets/widgets/validators/ledwidget.cpp
+++ b/examples/widgets/widgets/validators/ledwidget.cpp
@@ -56,7 +56,7 @@ LEDWidget::LEDWidget(QWidget *parent)
setPixmap(offPixmap);
flashTimer.setInterval(200);
flashTimer.setSingleShot(true);
- connect(&flashTimer, SIGNAL(timeout()), this, SLOT(extinguish()));
+ connect(&flashTimer, &QTimer::timeout, this, &LEDWidget::extinguish);
};
void LEDWidget::extinguish()
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
index 2f702c9753..7253fea9ec 100644
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ b/examples/widgets/widgets/validators/localeselector.cpp
@@ -79,7 +79,8 @@ LocaleSelector::LocaleSelector(QWidget *parent)
if (curIndex != -1)
setCurrentIndex(curIndex);
- connect(this, SIGNAL(activated(int)), this, SLOT(emitLocaleSelected(int)));
+ connect(this, QOverload<int>::of(&LocaleSelector::activated),
+ this, &LocaleSelector::emitLocaleSelected);
}
void LocaleSelector::emitLocaleSelected(int index)
diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp
index c19f23c513..e2abad89f4 100644
--- a/examples/widgets/widgets/windowflags/controllerwindow.cpp
+++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp
@@ -62,7 +62,8 @@ ControllerWindow::ControllerWindow(QWidget *parent)
createHintsGroupBox();
quitButton = new QPushButton(tr("&Quit"));
- connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+ connect(quitButton, &QPushButton::clicked,
+ qApp, &QApplication::quit);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@@ -220,7 +221,8 @@ void ControllerWindow::createHintsGroupBox()
QCheckBox *ControllerWindow::createCheckBox(const QString &text)
{
QCheckBox *checkBox = new QCheckBox(text);
- connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
+ connect(checkBox, &QCheckBox::clicked,
+ this, &ControllerWindow::updatePreview);
return checkBox;
}
//! [7]
@@ -229,7 +231,8 @@ QCheckBox *ControllerWindow::createCheckBox(const QString &text)
QRadioButton *ControllerWindow::createRadioButton(const QString &text)
{
QRadioButton *button = new QRadioButton(text);
- connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));
+ connect(button, &QRadioButton::clicked,
+ this, &ControllerWindow::updatePreview);
return button;
}
//! [8]
diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp
index 725a134daf..09e26fd7e4 100644
--- a/examples/widgets/widgets/windowflags/previewwindow.cpp
+++ b/examples/widgets/widgets/windowflags/previewwindow.cpp
@@ -61,7 +61,8 @@ PreviewWindow::PreviewWindow(QWidget *parent)
textEdit->setLineWrapMode(QTextEdit::NoWrap);
closeButton = new QPushButton(tr("&Close"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(closeButton, &QPushButton::clicked,
+ this, &PreviewWindow::close);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(textEdit);