[Interest] Compilation error with QtConcurrent::run

Constantin Makshin cmakshin at gmail.com
Wed Dec 10 21:52:54 CET 2014


I don't think the documentation on QtConcurrent::run() needs to be changed
because this problem is not related/specific to Qt.
On Dec 10, 2014 8:35 PM, "Juan Navarro" <oneorjuan at gmail.com> wrote:

> I did it creating a typedef for the needed method:
>
> typedef bool (QImage::*QImageSaveFn)(const QString&, const char*, int)
> const;
>
> And then issuing just like the sample given in the wiki:
>
> static QImage image = IPROJECT.getOutputCompositionImage();
> const QString fileName = "/tmp/w1.png";
> const char* format = "PNG";
> int quality = 0;
> QFuture<bool> future = QtConcurrent::run(
>             image, static_cast<QImageSaveFn>(&QImage::save),
>             fileName, format, quality);
>
> However if it wasn't for the additional comment by "daviddoria", that
> wouldn't have been obvious at all
>
> On Wed, Dec 10, 2014 at 5:19 PM, Juan Navarro <oneorjuan at gmail.com> wrote:
>
>> 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.
>>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141210/11a2b7d3/attachment.html>


More information about the Interest mailing list