diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0f6e6ba4254..e7ed9033f49 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,6 +3,8 @@ qt_examples_build_begin(EXTERNAL_BUILD) +add_compile_definitions(QT_NO_CONTEXTLESS_CONNECT) + add_subdirectory(corelib) add_subdirectory(embedded) if(TARGET Qt6::DBus) diff --git a/examples/corelib/bindableproperties/bindablesubscription/main.cpp b/examples/corelib/bindableproperties/bindablesubscription/main.cpp index dd4e26fb740..0eb8c1a76e0 100644 --- a/examples/corelib/bindableproperties/bindablesubscription/main.cpp +++ b/examples/corelib/bindableproperties/bindablesubscription/main.cpp @@ -28,29 +28,29 @@ int main(int argc, char *argv[]) // Initialize subscription data QRadioButton *monthly = w.findChild("btnMonthly"); - QObject::connect(monthly, &QRadioButton::clicked, [&] { + QObject::connect(monthly, &QRadioButton::clicked, monthly, [&] { subscription.setDuration(BindableSubscription::Monthly); }); QRadioButton *quarterly = w.findChild("btnQuarterly"); - QObject::connect(quarterly, &QRadioButton::clicked, [&] { + QObject::connect(quarterly, &QRadioButton::clicked, quarterly, [&] { subscription.setDuration(BindableSubscription::Quarterly); }); QRadioButton *yearly = w.findChild("btnYearly"); - QObject::connect(yearly, &QRadioButton::clicked, [&] { + QObject::connect(yearly, &QRadioButton::clicked, yearly, [&] { subscription.setDuration(BindableSubscription::Yearly); }); // Initialize user data QPushButton *germany = w.findChild("btnGermany"); - QObject::connect(germany, &QPushButton::clicked, [&] { + QObject::connect(germany, &QPushButton::clicked, germany, [&] { user.setCountry(BindableUser::Country::Germany); }); QPushButton *finland = w.findChild("btnFinland"); - QObject::connect(finland, &QPushButton::clicked, [&] { + QObject::connect(finland, &QPushButton::clicked, finland, [&] { user.setCountry(BindableUser::Country::Finland); }); QPushButton *norway = w.findChild("btnNorway"); - QObject::connect(norway, &QPushButton::clicked, [&] { + QObject::connect(norway, &QPushButton::clicked, norway, [&] { user.setCountry(BindableUser::Country::Norway); }); diff --git a/examples/corelib/bindableproperties/subscription/main.cpp b/examples/corelib/bindableproperties/subscription/main.cpp index 1f41486728c..db2188b16ca 100644 --- a/examples/corelib/bindableproperties/subscription/main.cpp +++ b/examples/corelib/bindableproperties/subscription/main.cpp @@ -64,25 +64,25 @@ int main(int argc, char *argv[]) // Track the price changes //! [connect-price-changed] - QObject::connect(&subscription, &Subscription::priceChanged, [&] { + QObject::connect(&subscription, &Subscription::priceChanged, priceDisplay, [&] { QLocale lc{QLocale::AnyLanguage, user.country()}; priceDisplay->setText(lc.toCurrencyString(subscription.price() / subscription.duration())); }); //! [connect-price-changed] //! [connect-validity-changed] - QObject::connect(&subscription, &Subscription::isValidChanged, [&] { + QObject::connect(&subscription, &Subscription::isValidChanged, priceDisplay, [&] { priceDisplay->setEnabled(subscription.isValid()); }); //! [connect-validity-changed] //! [connect-user] - QObject::connect(&user, &User::countryChanged, [&] { + QObject::connect(&user, &User::countryChanged, &subscription, [&] { subscription.calculatePrice(); subscription.updateValidity(); }); - QObject::connect(&user, &User::ageChanged, [&] { + QObject::connect(&user, &User::ageChanged, &subscription, [&] { subscription.updateValidity(); }); //! [connect-user] diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc index 7d1c997aeb9..3ef310db18e 100644 --- a/examples/sql/doc/src/drilldown.qdoc +++ b/examples/sql/doc/src/drilldown.qdoc @@ -154,10 +154,6 @@ We need to use lambdas for connecting the \c enableButtons slot because its signature does not match \c QTextEdit::textChanged and \c QComboBox::currentIndexChanged. - Since the latter has another overload with the signature - \c {const QString &} and the selected signal would be ambiguous, - we need to use \c QOverload::of to select a specific overload - for \c currentIndexChanged. We add all the widgets into a layout, store the item ID and the name of the displayed image file for future reference, and set diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp index 4f9896d74d3..614db9a9aa2 100644 --- a/examples/sql/drilldown/informationwindow.cpp +++ b/examples/sql/drilldown/informationwindow.cpp @@ -37,12 +37,8 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items, //! [3] //! [4] - connect(descriptionEditor, &QTextEdit::textChanged, [=]() { - enableButtons(); - }); - connect(imageFileEditor, &QComboBox::currentIndexChanged, [=]() { - enableButtons(); - }); + connect(descriptionEditor, &QTextEdit::textChanged, this, [this]() { enableButtons(); }); + connect(imageFileEditor, &QComboBox::currentIndexChanged, this, [this]() { enableButtons(); }); QFormLayout *formLayout = new QFormLayout; formLayout->addRow(itemLabel, itemText); diff --git a/examples/sql/sqlbrowser/browser.cpp b/examples/sql/sqlbrowser/browser.cpp index 98270fd5b5b..077e8df51c4 100644 --- a/examples/sql/sqlbrowser/browser.cpp +++ b/examples/sql/sqlbrowser/browser.cpp @@ -71,7 +71,7 @@ QSqlError Browser::addConnection(const QString &driver, const QString &dbName, c return err; } -void Browser::addConnection() +void Browser::openNewConnectionDialog() { QSqlConnectionDialog dialog(this); if (dialog.exec() != QDialog::Accepted) diff --git a/examples/sql/sqlbrowser/browser.h b/examples/sql/sqlbrowser/browser.h index cf959703b3e..82702b2ae3c 100644 --- a/examples/sql/sqlbrowser/browser.h +++ b/examples/sql/sqlbrowser/browser.h @@ -32,7 +32,7 @@ public slots: void exec(); void showTable(const QString &table); void showMetaData(const QString &table); - void addConnection(); + void openNewConnectionDialog(); void currentChanged() { updateActions(); } void about(); diff --git a/examples/sql/sqlbrowser/main.cpp b/examples/sql/sqlbrowser/main.cpp index c6babea96fb..445c04637ec 100644 --- a/examples/sql/sqlbrowser/main.cpp +++ b/examples/sql/sqlbrowser/main.cpp @@ -33,18 +33,17 @@ int main(int argc, char *argv[]) mainWin.setCentralWidget(&browser); QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File")); - fileMenu->addAction(QObject::tr("Add &Connection..."), - [&]() { browser.addConnection(); }); + fileMenu->addAction(QObject::tr("Add &Connection..."), &browser, + &Browser::openNewConnectionDialog); fileMenu->addSeparator(); - fileMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); }); + fileMenu->addAction(QObject::tr("&Quit"), qApp, &QApplication::quit); QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help")); - helpMenu->addAction(QObject::tr("About"), [&]() { browser.about(); }); - helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); }); + helpMenu->addAction(QObject::tr("About"), &browser, &Browser::about); + helpMenu->addAction(QObject::tr("About Qt"), qApp, &QApplication::aboutQt); - QObject::connect(&browser, &Browser::statusMessage, [&mainWin](const QString &text) { - mainWin.statusBar()->showMessage(text); - }); + QObject::connect(&browser, &Browser::statusMessage, &mainWin, + [&mainWin](const QString &text) { mainWin.statusBar()->showMessage(text); }); addConnectionsFromCommandline(app.arguments(), &browser); mainWin.show(); diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp index 34023eefdb2..037d97014c9 100644 --- a/examples/vulkan/hellovulkancubes/renderer.cpp +++ b/examples/vulkan/hellovulkancubes/renderer.cpp @@ -38,7 +38,7 @@ Renderer::Renderer(VulkanWindow *w, int initialCount) m_blockMesh.load(QStringLiteral(":/block.buf")); m_logoMesh.load(QStringLiteral(":/qt_logo.buf")); - QObject::connect(&m_frameWatcher, &QFutureWatcherBase::finished, [this] { + QObject::connect(&m_frameWatcher, &QFutureWatcherBase::finished, m_window, [this] { if (m_framePending) { m_framePending = false; m_window->frameReady();