summaryrefslogtreecommitdiffstats
path: root/src/concurrent/doc/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'src/concurrent/doc/snippets')
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp14
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp14
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp5
3 files changed, 9 insertions, 24 deletions
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
index d0deed4cc8..9b15eeaa99 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
@@ -145,19 +145,11 @@ bool QString::contains(const QRegularExpression &regexp) const;
//! [9]
-//! [10]
-std::bind(&QString::contains, QRegularExpression("^\\S+$")); // matches strings without whitespace
-//! [10]
-
-
-//! [11]
-bool contains(const QString &string)
-//! [11]
-
-
//! [12]
QStringList strings = ...;
-std::bind(static_cast<bool(QString::*)(const QRegularExpression&)>( &QString::contains ), QRegularExpression("..."));
+QFuture<QString> future = QtConcurrent::filtered(list, [](const QString &str) {
+ return str.contains(QRegularExpression("^\\S+$")); // matches strings without whitespace
+});
//! [12]
//! [13]
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
index 91e76be0db..183b82bb9a 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
@@ -158,19 +158,11 @@ QImage QImage::scaledToWidth(int width, Qt::TransformationMode) const;
//! [10]
-//! [11]
-std::bind(&QImage::scaledToWidth, 100, Qt::SmoothTransformation)
-//! [11]
-
-
-//! [12]
-QImage scaledToWith(const QImage &image)
-//! [12]
-
-
//! [13]
QList<QImage> images = ...;
-QFuture<QImage> thumbnails = QtConcurrent::mapped(images, std::bind(&QImage::scaledToWidth, 100, Qt::SmoothTransformation));
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, [](const QImage &img) {
+ return img.scaledToWidth(100, Qt::SmoothTransformation);
+});
//! [13]
//! [14]
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp
index 78e4591b0a..5437822842 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp
@@ -109,7 +109,8 @@ future.waitForFinished();
//! [6]
-void someFunction(int arg1, double arg2);
-QFuture<void> future = QtConcurrent::run(std::bind(someFunction, 1, 2.0));
+QFuture<void> future = QtConcurrent::run([=]() {
+ // Code in this block will run in another thread
+});
...
//! [6]