From ab9f4d5db6a4e183b9a26366e659ba642dedcbdd Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Thu, 3 Aug 2017 15:43:26 +0200 Subject: 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 --- examples/qtconcurrent/map/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'examples/qtconcurrent/map/main.cpp') 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 #include -QImage scale(const QImage &image) -{ - qDebug() << "Scaling image in thread" << QThread::currentThread(); - return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} +#include 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 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 thumbnails = QtConcurrent::blockingMapped(images, scale); -- cgit v1.2.3