From 7b74b4fbec299c2c8a9956a01d73beda69aee0df Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 19 Apr 2018 14:24:24 +0200 Subject: Doc: Update connect syntax Plugandpaint Example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-60635 Change-Id: I354a0886b22c63be57bd927308163abd3246be77 Reviewed-by: André Hartmann Reviewed-by: Paul Wicking Reviewed-by: Venugopal Shivashankar --- .../widgets/tools/plugandpaint/app/mainwindow.cpp | 28 +++++++++++----------- .../widgets/tools/plugandpaint/app/mainwindow.h | 4 +++- .../tools/plugandpaint/app/plugindialog.cpp | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'examples/widgets/tools') diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp index 12c65e9364..b2287ee072 100644 --- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp +++ b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp @@ -85,7 +85,7 @@ MainWindow::MainWindow() : if (!brushActionGroup->actions().isEmpty()) brushActionGroup->actions().first()->trigger(); - QTimer::singleShot(500, this, SLOT(aboutPlugins())); + QTimer::singleShot(500, this, &MainWindow::aboutPlugins); } void MainWindow::open() @@ -189,32 +189,32 @@ 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); saveAsAct = new QAction(tr("&Save As..."), this); saveAsAct->setShortcuts(QKeySequence::SaveAs); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); + connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs); 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); brushColorAct = new QAction(tr("&Brush Color..."), this); - connect(brushColorAct, SIGNAL(triggered()), this, SLOT(brushColor())); + connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor); brushWidthAct = new QAction(tr("&Brush Width..."), this); - connect(brushWidthAct, SIGNAL(triggered()), this, SLOT(brushWidth())); + connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth); brushActionGroup = new QActionGroup(this); 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); aboutPluginsAct = new QAction(tr("About &Plugins"), this); - connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins())); + connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins); } void MainWindow::createMenus() @@ -289,26 +289,26 @@ void MainWindow::populateMenus(QObject *plugin) { BrushInterface *iBrush = qobject_cast(plugin); if (iBrush) - addToMenu(plugin, iBrush->brushes(), brushMenu, SLOT(changeBrush()), + addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush, brushActionGroup); ShapeInterface *iShape = qobject_cast(plugin); if (iShape) - addToMenu(plugin, iShape->shapes(), shapesMenu, SLOT(insertShape())); + addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape); FilterInterface *iFilter = qobject_cast(plugin); if (iFilter) - addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter())); + addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter); } //! [10] void MainWindow::addToMenu(QObject *plugin, const QStringList &texts, - QMenu *menu, const char *member, + QMenu *menu, Member member, QActionGroup *actionGroup) { foreach (QString text, texts) { QAction *action = new QAction(text, plugin); - connect(action, SIGNAL(triggered()), this, member); + connect(action, &QAction::triggered, this, member); menu->addAction(action); if (actionGroup) { diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.h b/examples/widgets/tools/plugandpaint/app/mainwindow.h index 398759fecf..7d2c085c23 100644 --- a/examples/widgets/tools/plugandpaint/app/mainwindow.h +++ b/examples/widgets/tools/plugandpaint/app/mainwindow.h @@ -82,12 +82,14 @@ private slots: void aboutPlugins(); private: + typedef void (MainWindow::*Member)(); + void createActions(); void createMenus(); void loadPlugins(); void populateMenus(QObject *plugin); void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu, - const char *member, QActionGroup *actionGroup = 0); + Member member, QActionGroup *actionGroup = 0); PaintArea *paintArea; QScrollArea *scrollArea; diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp index 00c2498bd5..43eb34f423 100644 --- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp +++ b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp @@ -77,7 +77,7 @@ PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames, okButton->setDefault(true); - connect(okButton, SIGNAL(clicked()), this, SLOT(close())); + connect(okButton, &QAbstractButton::clicked, this, &QWidget::close); QGridLayout *mainLayout = new QGridLayout; mainLayout->setColumnStretch(0, 1); -- cgit v1.2.3