diff options
author | Michael Winkelmann <michael.winkelmann@qt.io> | 2017-08-03 15:43:26 +0200 |
---|---|---|
committer | Topi Reiniƶ <topi.reinio@qt.io> | 2017-11-07 09:42:34 +0000 |
commit | ab9f4d5db6a4e183b9a26366e659ba642dedcbdd (patch) | |
tree | 2661ab6baacd6ec545449619a749d8a9f4e43c54 /examples/qtconcurrent/map/main.cpp | |
parent | d4b3ce9a287b81eb9d7c6750ccca89e362343261 (diff) |
Revamp QtConcurrent examples to C++11
I updated signals and slots and for each loops to the new syntax and
replaced most free functions with std::function.
Task-number: QTBUG-60641
Change-Id: I7693f81f71c7f53fcbe83189a0de2fb76ddf99a8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'examples/qtconcurrent/map/main.cpp')
-rw-r--r-- | examples/qtconcurrent/map/main.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/qtconcurrent/map/main.cpp b/examples/qtconcurrent/map/main.cpp index d01b91fe55..8fc670b64b 100644 --- a/examples/qtconcurrent/map/main.cpp +++ b/examples/qtconcurrent/map/main.cpp @@ -55,11 +55,7 @@ #include <QGuiApplication> #include <qtconcurrentmap.h> -QImage scale(const QImage &image) -{ - qDebug() << "Scaling image in thread" << QThread::currentThread(); - return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} +#include <functional> int main(int argc, char *argv[]) { @@ -72,6 +68,12 @@ int main(int argc, char *argv[]) for (int i = 0; i < imageCount; ++i) images.append(QImage(1600, 1200, QImage::Format_ARGB32_Premultiplied)); + std::function<QImage(const QImage&)> scale = [](const QImage &image) -> QImage + { + qDebug() << "Scaling image in thread" << QThread::currentThread(); + return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + }; + // Use QtConcurrentBlocking::mapped to apply the scale function to all the // images in the list. QList<QImage> thumbnails = QtConcurrent::blockingMapped(images, scale); |