summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/qlistview-dnd/model.cpp
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/qlistview-dnd/model.cpp
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/qlistview-dnd/model.cpp')
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.cpp b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
index 710bbb2964..6835479e7a 100644
--- a/src/widgets/doc/snippets/qlistview-dnd/model.cpp
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
@@ -54,7 +54,7 @@
A simple model that uses a QStringList as its data source.
*/
-#include <QtGui>
+#include <QtWidgets>
#include "model.h"
@@ -121,7 +121,7 @@ bool DragDropListModel::dropMimeData(const QMimeData *data,
//! [6]
insertRows(beginRow, rows, QModelIndex());
- foreach (const QString &text, newItems) {
+ for (const QString &text : qAsConst(newItems)) {
QModelIndex idx = index(beginRow, 0, QModelIndex());
setData(idx, text);
beginRow++;
@@ -146,12 +146,12 @@ Qt::ItemFlags DragDropListModel::flags(const QModelIndex &index) const
//! [8]
QMimeData *DragDropListModel::mimeData(const QModelIndexList &indexes) const
{
- QMimeData *mimeData = new QMimeData();
+ QMimeData *mimeData = new QMimeData;
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
- foreach (const QModelIndex &index, indexes) {
+ for (const QModelIndex &index : indexes) {
if (index.isValid()) {
QString text = data(index, Qt::DisplayRole).toString();
stream << text;