[Interest] Compilation error with QtConcurrent::run

Juan Navarro oneorjuan at gmail.com
Wed Dec 10 17:19:44 CET 2014

I'm following this: http://qt-project.org/doc/qt-4.8/qtconcurrentrun.html

But the given example for calling member functions doesn't work for at
least one Qt class / method:
bool QImage::save(const QString &fileName, const char* format=0, int
quality=-1) const;

The compiler cannot decide which of the QImage::save overloads must choose
("unresolved overloaded function type").

This is the code:
QImage image = ...
QFuture<bool> future = QtConcurrent::run(image, &QImage::save,
QString("test.png"), "PNG", 0);

This also fails:
const QImage image = ...
const QString fileName = "test.png";
const char* format = "PNG";
int quality = 0;
QFuture<bool> future = QtConcurrent::run(image, &QImage::save, fileName,
format, quality);

And this is the error:
error: no matching function for call to 'run(QImage&, <unresolved
overloaded function type>, QString, const char [4], int)'
QFuture<bool> future = QtConcurrent::run(image, &QImage::save,
QString("/tmp/w1.png"), "PNG", 0);

I'm trying to specify the exact method signature in the QtConcurrent::run
call to see if it works; meanwhile I just wanted to check with you if a bug
report to the Documentation would be appropriate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141210/43cdc803/attachment.html>

More information about the Interest mailing list