From 42a9fe3042945937839eda3578655ca091422b28 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 23 Aug 2010 12:16:59 +0200 Subject: Doc: QtConcurrent::run. Make sure the example actually compiles QString::split has overload, and if you want to take the address of a function with overload, you need to cast it. If we really wanted to use QString::split, we would have to do QFuture future = QtConcurrent::run(string, static_cast(&QString::split), QString (", "), QString::KeepEmptyParts, Qt::CaseSensitive); So use QByteArray::split as an example instead Task-number: QTBUG-12897 Reviewed-by: David Boddie --- .../snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp | 10 ++++------ src/corelib/concurrent/qtconcurrentrun.cpp | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp index 8f74461..cea6553 100644 --- a/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp +++ b/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp @@ -73,16 +73,14 @@ QFuture future = QtConcurrent::run(someFunction, bytearray); QString result = future.result(); //! [3] - //! [4] -// call 'QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const' in a separate thread -QString string = ...; -QFuture future = QtConcurrent::run(string, &QString::split, QString(", "), QString::KeepEmptyParts, Qt::CaseSensitive); +// call 'QList QByteArray::split(char sep) const' in a separate thread +QByteArray bytearray = "hello world; +QFuture > future = QtConcurrent::run(bytearray, &QByteArray::split), ','); ... -QStringList result = future.result(); +QList result = future.result(); //! [4] - //! [5] // call 'void QImage::invertPixels(InvertMode mode)' in a separate thread QImage image = ...; diff --git a/src/corelib/concurrent/qtconcurrentrun.cpp b/src/corelib/concurrent/qtconcurrentrun.cpp index 5a9c755..e80a204 100644 --- a/src/corelib/concurrent/qtconcurrentrun.cpp +++ b/src/corelib/concurrent/qtconcurrentrun.cpp @@ -99,7 +99,7 @@ functions; passing by pointer is useful for calling non-const member functions that modify the instance. - For example, calling QString::split() (a const member function) in a + For example, calling QByteArray::split() (a const member function) in a separate thread is done like this: \snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 4 -- cgit v0.12