summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/updating-selections
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-03 19:55:51 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-02-05 16:54:53 +0000
commit3514aedbf36b96f6e03f88c9c7814b6ba50aac8f (patch)
tree12b217941ade632b464a365acf3dc6be7ce8509d /src/widgets/doc/snippets/updating-selections
parentb76a923a8e81f5fabe6e48ed467e5326275fae4e (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/updating-selections')
-rw-r--r--src/widgets/doc/snippets/updating-selections/window.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/widgets/doc/snippets/updating-selections/window.cpp b/src/widgets/doc/snippets/updating-selections/window.cpp
index 0bdcf8a64d..26e9b56ae4 100644
--- a/src/widgets/doc/snippets/updating-selections/window.cpp
+++ b/src/widgets/doc/snippets/updating-selections/window.cpp
@@ -74,12 +74,10 @@ MainWindow::MainWindow(QWidget *parent)
table->setModel(model);
selectionModel = table->selectionModel();
- connect(selectionModel,
- SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(updateSelection(QItemSelection,QItemSelection)));
- connect(selectionModel,
- SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- this, SLOT(changeCurrent(QModelIndex,QModelIndex)));
+ connect(selectionModel, &QItemSelectionModel::selectionChanged,
+ this, &MainWindow::updateSelection);
+ connect(selectionModel, &QItemSelectionModel::currentChanged,
+ this, &MainWindow::changeCurrent);
statusBar();
setCentralWidget(table);
@@ -89,10 +87,9 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::updateSelection(const QItemSelection &selected,
const QItemSelection &deselected)
{
- QModelIndex index;
QModelIndexList items = selected.indexes();
- foreach (index, items) {
+ for (const QModelIndex &index : qAsConst(items)) {
QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
model->setData(index, text);
//! [0] //! [1]
@@ -102,8 +99,8 @@ void MainWindow::updateSelection(const QItemSelection &selected,
//! [2]
items = deselected.indexes();
- foreach (index, items)
- model->setData(index, "");
+ for (const QModelIndex &index : qAsConst(items)) {
+ model->setData(index, QString());
}
//! [2]