From 3514aedbf36b96f6e03f88c9c7814b6ba50aac8f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Feb 2019 19:55:51 +0100 Subject: QtWidgets documentation: cleanup Cleanup the QtWidgets documentation: - use new signal/slot syntax - use range-based for loop instead foreach Change-Id: I621b1ddac108d3df676209241d93d9b4f04a25fe Reviewed-by: Friedemann Kleint --- src/widgets/doc/snippets/reading-selections/window.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/widgets/doc/snippets/reading-selections/window.cpp') diff --git a/src/widgets/doc/snippets/reading-selections/window.cpp b/src/widgets/doc/snippets/reading-selections/window.cpp index 08805fe4b32..045d66a199b 100644 --- a/src/widgets/doc/snippets/reading-selections/window.cpp +++ b/src/widgets/doc/snippets/reading-selections/window.cpp @@ -81,9 +81,9 @@ MainWindow::MainWindow(QWidget *parent) QAction *selectAllAction = actionMenu->addAction(tr("&Select All")); menuBar()->addMenu(actionMenu); - connect(fillAction, SIGNAL(triggered()), this, SLOT(fillSelection())); - connect(clearAction, SIGNAL(triggered()), this, SLOT(clearSelection())); - connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll())); + connect(fillAction, &QAction::triggered, this, &MainWindow::fillSelection); + connect(clearAction, &QAction::triggered, this, &MainWindow::clearSelection); + connect(selectAllAction, &QAction::triggered, this, &MainWindow::selectAll); selectionModel = table->selectionModel(); @@ -94,10 +94,9 @@ MainWindow::MainWindow(QWidget *parent) void MainWindow::fillSelection() { //! [0] - QModelIndexList indexes = selectionModel->selectedIndexes(); - QModelIndex index; + const QModelIndexList indexes = selectionModel->selectedIndexes(); - foreach(index, indexes) { + for (const QModelIndex &index : indexes) { QString text = QString("(%1,%2)").arg(index.row()).arg(index.column()); model->setData(index, text); } @@ -106,11 +105,10 @@ void MainWindow::fillSelection() void MainWindow::clearSelection() { - QModelIndexList indexes = selectionModel->selectedIndexes(); - QModelIndex index; + const QModelIndexList indexes = selectionModel->selectedIndexes(); - foreach(index, indexes) - model->setData(index, ""); + for (const QModelIndex &index : indexes) + model->setData(index, QString()); } void MainWindow::selectAll() -- cgit v1.2.3