diff options
Diffstat (limited to 'examples')
25 files changed, 43 insertions, 94 deletions
diff --git a/examples/corelib/ipc/ipc.pro b/examples/corelib/ipc/ipc.pro index 4cc5f3be56..101552cea9 100644 --- a/examples/corelib/ipc/ipc.pro +++ b/examples/corelib/ipc/ipc.pro @@ -1,6 +1,6 @@ requires(qtHaveModule(widgets)) TEMPLATE = subdirs -# no QSharedMemory -!vxworks:!integrity: SUBDIRS = sharedmemory + +qtConfig(sharedmemory): SUBDIRS = sharedmemory qtHaveModule(network): SUBDIRS += localfortuneserver localfortuneclient diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index 205959936d..c0043e246f 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -122,8 +122,7 @@ Client::Client(QWidget *parent) //! [2] //! [3] connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune); //! [2] //! [4] - typedef void (QAbstractSocket::*QAbstractSocketErrorSignal)(QAbstractSocket::SocketError); - connect(tcpSocket, static_cast<QAbstractSocketErrorSignal>(&QAbstractSocket::error), + connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), //! [3] this, &Client::displayError); //! [4] diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 6e031e5cb7..799431a765 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -95,9 +95,7 @@ PaintedWindow::PaintedWindow() 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)); + connect(this, &PaintedWindow::rotationChanged, this, QOverload<>::of(&PaintedWindow::paint)); } void PaintedWindow::exposeEvent(QExposeEvent *) diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp index f602c9995b..1bb2aa2bf0 100644 --- a/examples/opengl/qopenglwidget/mainwindow.cpp +++ b/examples/opengl/qopenglwidget/mainwindow.cpp @@ -61,8 +61,6 @@ #include "glwidget.h" -typedef void (QWidget::*QWidgetVoidSlot)(); - MainWindow::MainWindow() : m_nextX(1), m_nextY(1) { @@ -131,14 +129,11 @@ MainWindow::MainWindow() QMenu *helpMenu = menuBar()->addMenu("&Help"); helpMenu->addAction("About Qt", qApp, &QApplication::aboutQt); - connect(m_timer, &QTimer::timeout, - glwidget, static_cast<QWidgetVoidSlot>(&QWidget::update)); + connect(m_timer, &QTimer::timeout, glwidget, QOverload<>::of(&QWidget::update)); connect(slider, &QAbstractSlider::valueChanged, glwidget, &GLWidget::setScaling); connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent); - - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(updateInterval, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged), + connect(updateInterval, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::updateIntervalChanged); connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged); connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled); @@ -162,7 +157,7 @@ void MainWindow::addNew() return; GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256)); m_glWidgets << w; - connect(m_timer, &QTimer::timeout, w, static_cast<QWidgetVoidSlot>(&QWidget::update)); + connect(m_timer, &QTimer::timeout, w, QOverload<>::of(&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 4287d42d24..4f008b45a6 100644 --- a/examples/opengl/qopenglwindow/main.cpp +++ b/examples/opengl/qopenglwindow/main.cpp @@ -173,8 +173,6 @@ 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 @@ -182,11 +180,11 @@ void OpenGLWindow::setAnimating(bool enabled) // obviously assumes that the swap interval (see // QSurfaceFormat::setSwapInterval()) is non-zero. connect(this, &QOpenGLWindow::frameSwapped, - this, static_cast<QPaintDeviceWindowVoidSlot>(&QPaintDeviceWindow::update)); + this, QOverload<>::of(&QPaintDeviceWindow::update)); update(); } else { disconnect(this, &QOpenGLWindow::frameSwapped, - this, static_cast<QPaintDeviceWindowVoidSlot>(&QPaintDeviceWindow::update)); + this, QOverload<>::of(&QPaintDeviceWindow::update)); } } diff --git a/examples/qtconcurrent/imagescaling/imagescaling.pro b/examples/qtconcurrent/imagescaling/imagescaling.pro index da237bd6af..110f8f1b0b 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.pro +++ b/examples/qtconcurrent/imagescaling/imagescaling.pro @@ -5,5 +5,3 @@ HEADERS += imagescaling.h target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/imagescaling INSTALLS += target - -wince: DEPLOYMENT_PLUGIN += qgif qjpeg diff --git a/examples/sql/sqlbrowser/sqlbrowser.pro b/examples/sql/sqlbrowser/sqlbrowser.pro index 539796fe71..1cc13d754f 100644 --- a/examples/sql/sqlbrowser/sqlbrowser.pro +++ b/examples/sql/sqlbrowser/sqlbrowser.pro @@ -15,8 +15,3 @@ build_all:!build_pass { # install target.path = $$[QT_INSTALL_EXAMPLES]/sql/sqlbrowser INSTALLS += target - - -wince { - DEPLOYMENT_PLUGIN += qsqlite -} diff --git a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro index 44815407d7..fe600a9124 100644 --- a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro +++ b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro @@ -7,6 +7,4 @@ QT += sql widgets target.path = $$[QT_INSTALL_EXAMPLES]/sql/sqlwidgetmapper INSTALLS += target -wince: DEPLOYMENT_PLUGIN += qsqlite - diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp index 6438eb27cc..80f26ae282 100644 --- a/examples/widgets/desktop/screenshot/screenshot.cpp +++ b/examples/widgets/desktop/screenshot/screenshot.cpp @@ -70,8 +70,7 @@ Screenshot::Screenshot() delaySpinBox->setSuffix(tr(" s")); delaySpinBox->setMaximum(60); - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(delaySpinBox, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged), + connect(delaySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Screenshot::updateCheckBox); hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window"), optionsGroupBox); diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index ac05f16341..05944c92a7 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -80,8 +80,7 @@ Window::Window() connect(showMessageButton, &QAbstractButton::clicked, this, &Window::showMessage); connect(showIconCheckBox, &QAbstractButton::toggled, trayIcon, &QSystemTrayIcon::setVisible); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(iconComboBox, static_cast<QComboIntSignal>(&QComboBox::currentIndexChanged), + connect(iconComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Window::setIcon); connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked); connect(trayIcon, &QSystemTrayIcon::activated, this, &Window::iconActivated); diff --git a/examples/widgets/dialogs/classwizard/classwizard.cpp b/examples/widgets/dialogs/classwizard/classwizard.cpp index d6c7c7a546..3eab2f5fb2 100644 --- a/examples/widgets/dialogs/classwizard/classwizard.cpp +++ b/examples/widgets/dialogs/classwizard/classwizard.cpp @@ -363,9 +363,10 @@ void CodeStylePage::initializePage() baseIncludeLabel->setEnabled(!baseClass.isEmpty()); baseIncludeLineEdit->setEnabled(!baseClass.isEmpty()); + QRegularExpression rx("Q[A-Z].*"); if (baseClass.isEmpty()) { baseIncludeLineEdit->clear(); - } else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) { + } else if (rx.match(baseClass).hasMatch()) { baseIncludeLineEdit->setText('<' + baseClass + '>'); } else { baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\""); diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index e145a18e2c..6dbb894ad8 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -54,6 +54,8 @@ #include "licensewizard.h" +QString emailRegExp = QStringLiteral(".+@.+"); + //! [0] //! [1] //! [2] LicenseWizard::LicenseWizard(QWidget *parent) : QWizard(parent) @@ -189,7 +191,7 @@ EvaluatePage::EvaluatePage(QWidget *parent) emailLabel = new QLabel(tr("&Email address:")); emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(emailRegExp), this)); emailLabel->setBuddy(emailLineEdit); //! [21] @@ -264,7 +266,7 @@ DetailsPage::DetailsPage(QWidget *parent) emailLabel = new QLabel(tr("&Email address:")); emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(emailRegExp), this)); emailLabel->setBuddy(emailLineEdit); postalLabel = new QLabel(tr("&Postal address:")); diff --git a/examples/widgets/doc/src/icons.qdoc b/examples/widgets/doc/src/icons.qdoc index d3bf508f2c..42d823975b 100644 --- a/examples/widgets/doc/src/icons.qdoc +++ b/examples/widgets/doc/src/icons.qdoc @@ -741,8 +741,8 @@ whitespace and one or several digits again. The first digits of the regular expression are captured using - parentheses. This enables us to use the QRegExp::cap() or - QRegExp::capturedTexts() functions to extract the matched + parentheses. This enables us to use the QRegularExpressionMatch::captured() + or QRegularExpressionMatch::capturedTexts() functions to extract the matched characters. If the first and second numbers of the spin box value differ (e.g., "16 x 24"), we use the first number. diff --git a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp index a8a8875f6b..b45ee47ee2 100644 --- a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp +++ b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp @@ -89,11 +89,9 @@ Window::Window() connect(filterPatternLineEdit, &QLineEdit::textChanged, this, &Window::filterRegExpChanged); - - typedef void (QComboBox::*QComboIntSignal)(int); - connect(filterSyntaxComboBox, static_cast<QComboIntSignal>(&QComboBox::currentIndexChanged), + connect(filterSyntaxComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Window::filterRegExpChanged); - connect(filterColumnComboBox, static_cast<QComboIntSignal>(&QComboBox::currentIndexChanged), + connect(filterColumnComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Window::filterColumnChanged); connect(filterCaseSensitivityCheckBox, &QAbstractButton::toggled, this, &Window::filterRegExpChanged); diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp index a5a704a864..2a5b572344 100644 --- a/examples/widgets/itemviews/pixelator/mainwindow.cpp +++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp @@ -113,10 +113,9 @@ MainWindow::MainWindow() connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); connect(aboutAction, &QAction::triggered, this, &MainWindow::showAboutBox); //! [4] - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(pixelSizeSpinBox, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged), + connect(pixelSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), delegate, &PixelDelegate::setPixelSize); - connect(pixelSizeSpinBox, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged), + connect(pixelSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::updateView); //! [4] diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp index a21a64bdd4..10e3dd045a 100644 --- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp +++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp @@ -282,23 +282,10 @@ void MainWindow::loadLayout() } } -class DockWidgetAreaCornerFunctor { -public: - explicit DockWidgetAreaCornerFunctor(QMainWindow *mw, Qt::Corner c, Qt::DockWidgetArea a) - : m_mainWindow(mw), m_area(a), m_corner(c) {} - - void operator()() const { m_mainWindow->setCorner(m_corner, m_area); } - -private: - QMainWindow *m_mainWindow; - Qt::DockWidgetArea m_area; - Qt::Corner m_corner; -}; - static QAction *addCornerAction(const QString &text, QMainWindow *mw, QMenu *menu, QActionGroup *group, Qt::Corner c, Qt::DockWidgetArea a) { - QAction *result = menu->addAction(text, mw, DockWidgetAreaCornerFunctor(mw, c, a)); + QAction *result = menu->addAction(text, mw, [=]() { mw->setCorner(c, a); }); result->setCheckable(true); group->addAction(result); return result; diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp index 76b1c308cb..188de1893e 100644 --- a/examples/widgets/mainwindows/mdi/mainwindow.cpp +++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp @@ -264,16 +264,6 @@ void MainWindow::updateMenus() #endif } -class ActiveMdiSubWindowFunctor { -public: - explicit ActiveMdiSubWindowFunctor(QMdiArea *mdiArea, QMdiSubWindow *activeWindow) : m_mdiArea(mdiArea), m_activeWindow(activeWindow) {} - void operator()() const { m_mdiArea->setActiveSubWindow(m_activeWindow); } - -private: - QMdiArea *m_mdiArea; - QMdiSubWindow *m_activeWindow; -}; - void MainWindow::updateWindowMenu() { windowMenu->clear(); @@ -302,7 +292,9 @@ void MainWindow::updateWindowMenu() text = tr("%1 %2").arg(i + 1) .arg(child->userFriendlyCurrentFile()); } - QAction *action = windowMenu->addAction(text, mdiSubWindow, ActiveMdiSubWindowFunctor(mdiArea, mdiSubWindow)); + QAction *action = windowMenu->addAction(text, mdiSubWindow, [this, mdiSubWindow]() { + mdiArea->setActiveSubWindow(mdiSubWindow); + }); action->setCheckable(true); action ->setChecked(child == activeMdiChild()); } diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index dec0b0bd35..140ae478ff 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -342,13 +342,11 @@ void TextEdit::setupTextActions() comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(comboStyle, static_cast<QComboIntSignal>(&QComboBox::activated), this, &TextEdit::textStyle); + connect(comboStyle, QOverload<int>::of(&QComboBox::activated), this, &TextEdit::textStyle); - typedef void (QComboBox::*QComboStringSignal)(const QString &); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); - connect(comboFont, static_cast<QComboStringSignal>(&QComboBox::activated), this, &TextEdit::textFamily); + connect(comboFont, QOverload<const QString &>::of(&QComboBox::activated), this, &TextEdit::textFamily); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); @@ -360,7 +358,7 @@ void TextEdit::setupTextActions() comboSize->addItem(QString::number(size)); comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize())); - connect(comboSize, static_cast<QComboStringSignal>(&QComboBox::activated), this, &TextEdit::textSize); + connect(comboSize, QOverload<const QString &>::of(&QComboBox::activated), this, &TextEdit::textSize); } bool TextEdit::load(const QString &f) diff --git a/examples/widgets/tools/codecs/previewform.cpp b/examples/widgets/tools/codecs/previewform.cpp index e5ca13f011..d19b9c0833 100644 --- a/examples/widgets/tools/codecs/previewform.cpp +++ b/examples/widgets/tools/codecs/previewform.cpp @@ -159,8 +159,7 @@ PreviewForm::PreviewForm(QWidget *parent) new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); okButton = buttonBox->button(QDialogButtonBox::Ok); - typedef void(QComboBox::*ComboBoxIntSignal)(int); - connect(encodingComboBox, static_cast<ComboBoxIntSignal>(&QComboBox::activated), + connect(encodingComboBox, QOverload<int>::of(&QComboBox::activated), this, &PreviewForm::updateTextEdit); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp index f13240d06f..7a67c763d8 100644 --- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp +++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp @@ -94,10 +94,10 @@ RegularExpressionDialog::RegularExpressionDialog(QWidget *parent) connect(optimizeOnFirstUsageOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); connect(dontAutomaticallyOptimizeOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); - connect(offsetSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + connect(offsetSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &RegularExpressionDialog::refresh); - connect(matchTypeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + connect(matchTypeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RegularExpressionDialog::refresh); connect(anchoredMatchOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); diff --git a/examples/widgets/tools/settingseditor/locationdialog.cpp b/examples/widgets/tools/settingseditor/locationdialog.cpp index 4aa1e6073f..5b6e2652bb 100644 --- a/examples/widgets/tools/settingseditor/locationdialog.cpp +++ b/examples/widgets/tools/settingseditor/locationdialog.cpp @@ -106,10 +106,9 @@ LocationDialog::LocationDialog(QWidget *parent) buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(formatComboBox, static_cast<QComboIntSignal>(&QComboBox::activated), + connect(formatComboBox, QOverload<int>::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); - connect(scopeComboBox, static_cast<QComboIntSignal>(&QComboBox::activated), + connect(scopeComboBox, QOverload<int>::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); connect(organizationComboBox->lineEdit(), &QLineEdit::editingFinished, @@ -117,7 +116,7 @@ LocationDialog::LocationDialog(QWidget *parent) connect(applicationComboBox->lineEdit(), &QLineEdit::editingFinished, this, &LocationDialog::updateLocationsTable); - connect(applicationComboBox, static_cast<QComboIntSignal>(&QComboBox::activated), + connect(applicationComboBox, QOverload<int>::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp index 8fabcf8758..e946c873e3 100644 --- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp +++ b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp @@ -402,7 +402,7 @@ void AddressBook::exportAsVCard() int index = name.indexOf(" "); if (index != -1) { - nameList = name.split(QRegExp("\\s+"), QString::SkipEmptyParts); + nameList = name.split(QRegularExpression("\\s+"), QString::SkipEmptyParts); firstName = nameList.first(); lastName = nameList.last(); } else { diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index 8b406ba1ca..5f17128a2f 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -74,8 +74,7 @@ MainWindow::MainWindow() filterCombo->addItem(tr("Monospaced"), QVariant::fromValue(QFontComboBox::MonospacedFonts)); filterCombo->addItem(tr("Proportional"), QVariant::fromValue(QFontComboBox::ProportionalFonts)); filterCombo->setCurrentIndex(0); - typedef void (QComboBox::*QComboBoxIntSignal)(int); - connect(filterCombo, static_cast<QComboBoxIntSignal>(&QComboBox::currentIndexChanged), + connect(filterCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::filterChanged); QLabel *fontLabel = new QLabel(tr("Font:")); @@ -114,10 +113,9 @@ MainWindow::MainWindow() this, &MainWindow::findSizes); connect(fontCombo, &QFontComboBox::currentFontChanged, characterWidget, &CharacterWidget::updateFont); - typedef void (QComboBox::*QComboBoxStringSignal)(const QString &); - connect(sizeCombo, static_cast<QComboBoxStringSignal>(&QComboBox::currentIndexChanged), + connect(sizeCombo, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), characterWidget, &CharacterWidget::updateSize); - connect(styleCombo, static_cast<QComboBoxStringSignal>(&QComboBox::currentIndexChanged), + connect(styleCombo, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), characterWidget, &CharacterWidget::updateStyle); //! [4] //! [5] connect(characterWidget, &CharacterWidget::characterSelected, diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp index 980013daee..3c873f1e24 100644 --- a/examples/widgets/widgets/icons/imagedelegate.cpp +++ b/examples/widgets/widgets/icons/imagedelegate.cpp @@ -71,8 +71,7 @@ QWidget *ImageDelegate::createEditor(QWidget *parent, else if (index.column() == 2) comboBox->addItems(IconPreviewArea::iconStateNames()); - typedef void (QComboBox::*QComboBoxIntSignal)(int); - connect(comboBox, static_cast<QComboBoxIntSignal>(&QComboBox::activated), + connect(comboBox, QOverload<int>::of(&QComboBox::activated), this, &ImageDelegate::emitCommitData); return comboBox; diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp index 5f3882de94..f704b8306f 100644 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ b/examples/widgets/widgets/icons/mainwindow.cpp @@ -362,8 +362,7 @@ QWidget *MainWindow::createIconSizeGroupBox() sizeButtonGroup = new QButtonGroup(this); sizeButtonGroup->setExclusive(true); - typedef void (QButtonGroup::*QButtonGroupIntBoolSignal)(int, bool); - connect(sizeButtonGroup, static_cast<QButtonGroupIntBoolSignal>(&QButtonGroup::buttonToggled), + connect(sizeButtonGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), this, &MainWindow::changeSize); QRadioButton *smallRadioButton = new QRadioButton; @@ -391,8 +390,7 @@ QWidget *MainWindow::createIconSizeGroupBox() //! [26] //! [27] - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(otherSpinBox, static_cast<QSpinBoxIntSignal>(&QSpinBox::valueChanged), + connect(otherSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::triggerChangeSize); QHBoxLayout *otherSizeLayout = new QHBoxLayout; |