diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-02-03 19:55:51 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-02-05 16:54:53 +0000 |
commit | 3514aedbf36b96f6e03f88c9c7814b6ba50aac8f (patch) | |
tree | 12b217941ade632b464a365acf3dc6be7ce8509d /src/widgets/doc/snippets/reading-selections/window.cpp | |
parent | b76a923a8e81f5fabe6e48ed467e5326275fae4e (diff) |
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/widgets/doc/snippets/reading-selections/window.cpp')
-rw-r--r-- | src/widgets/doc/snippets/reading-selections/window.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/widgets/doc/snippets/reading-selections/window.cpp b/src/widgets/doc/snippets/reading-selections/window.cpp index 08805fe4b3..045d66a199 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() |