From c158f881b30a28ab28ede0df538cbf1af4326c76 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 25 Feb 2020 16:49:05 +0100 Subject: Docs: Use Qt::SplitBehavior in preference to QString::SplitBehavior The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step closer to that goal. Applied suitable wrapping round various char and string literals, since docs are meant to show best practice. Change-Id: Ie061905fad26f9b4dda3eedba4612704f0a19126 Reviewed-by: Lars Knoll --- examples/widgets/draganddrop/draggabletext/dragwidget.cpp | 2 +- examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp | 4 ++-- examples/widgets/graphicsview/flowlayout/window.cpp | 2 +- examples/widgets/itemviews/chart/mainwindow.cpp | 2 +- examples/widgets/itemviews/editabletreemodel/treemodel.cpp | 3 ++- examples/widgets/itemviews/simpletreemodel/treemodel.cpp | 3 ++- examples/widgets/tutorials/addressbook/part7/addressbook.cpp | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp index 2135ba2ef9..4a430ebf56 100644 --- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp @@ -113,7 +113,7 @@ void DragWidget::dropEvent(QDropEvent *event) if (event->mimeData()->hasText()) { const QMimeData *mime = event->mimeData(); QStringList pieces = mime->text().split(QRegularExpression(QStringLiteral("\\s+")), - QString::SkipEmptyParts); + Qt::SkipEmptyParts); QPoint position = event->pos(); QPoint hotSpot; diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp index 4fbc6d3fd9..a02b1cb42a 100644 --- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp +++ b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp @@ -163,8 +163,8 @@ void DragWidget::dropEvent(QDropEvent *event) } //! [11] //! [12] } else if (event->mimeData()->hasText()) { - QStringList pieces = event->mimeData()->text().split(QRegularExpression(QStringLiteral("\\s+")), - QString::SkipEmptyParts); + QStringList pieces = event->mimeData()->text().split( + QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts); QPoint position = event->pos(); for (const QString &piece : pieces) { diff --git a/examples/widgets/graphicsview/flowlayout/window.cpp b/examples/widgets/graphicsview/flowlayout/window.cpp index 8fe06d0e11..0edaa686b4 100644 --- a/examples/widgets/graphicsview/flowlayout/window.cpp +++ b/examples/widgets/graphicsview/flowlayout/window.cpp @@ -59,7 +59,7 @@ Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window) FlowLayout *lay = new FlowLayout; const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown." " I am bothered when I do not know others. (Confucius)")); - const QVector words = sentence.splitRef(QLatin1Char(' '), QString::SkipEmptyParts); + const QVector words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts); for (const QStringRef &word : words) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); QLabel *label = new QLabel(word.toString()); diff --git a/examples/widgets/itemviews/chart/mainwindow.cpp b/examples/widgets/itemviews/chart/mainwindow.cpp index 53f57fbb49..671cfb1941 100644 --- a/examples/widgets/itemviews/chart/mainwindow.cpp +++ b/examples/widgets/itemviews/chart/mainwindow.cpp @@ -134,7 +134,7 @@ void MainWindow::loadFile(const QString &fileName) if (!line.isEmpty()) { model->insertRows(row, 1, QModelIndex()); - const QStringList pieces = line.split(',', QString::SkipEmptyParts); + const QStringList pieces = line.split(QLatin1Char(','), Qt::SkipEmptyParts); if (pieces.size() < 3) continue; model->setData(model->index(row, 0, QModelIndex()), diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp index 836c2e8651..9678e45be7 100644 --- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp +++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp @@ -267,7 +267,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) if (!lineData.isEmpty()) { // Read the column data from the rest of the line. - const QStringList columnStrings = lineData.split('\t', QString::SkipEmptyParts); + const QStringList columnStrings = + lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts); QVector columnData; columnData.reserve(columnStrings.size()); for (const QString &columnString : columnStrings) diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp index cfa65846ed..28640d6433 100644 --- a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp +++ b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp @@ -194,7 +194,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) if (!lineData.isEmpty()) { // Read the column data from the rest of the line. - const QStringList columnStrings = lineData.split('\t', QString::SkipEmptyParts); + const QStringList columnStrings = + lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts); QVector columnData; columnData.reserve(columnStrings.count()); for (const QString &columnString : columnStrings) diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp index 717d0882af..1ba23756c4 100644 --- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp +++ b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp @@ -413,7 +413,7 @@ void AddressBook::exportAsVCard() int index = name.indexOf(" "); if (index != -1) { - nameList = name.split(QRegularExpression("\\s+"), QString::SkipEmptyParts); + nameList = name.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts); firstName = nameList.first(); lastName = nameList.last(); } else { -- cgit v1.2.3