Please nominate your Qt Champions for 2021!

[SOLVED] Problem to compile with QtConcurrent with msvc2010 and qt 4.8.2

  • Hello,

    maybe somebody have an idea about this problem :

    i have put an exemple to try.

    thanks in advance

  • Looks like the compiler cannot correctly deduce the template to instantiate. You should give him a little help:

    @QFuture<QVariant> _f = QtConcurrent::run<QVariant>(this, &MJaoWidgetProperty::__render_function, &pA, &pB, true, true);@

    The template parameter for QFuture must be QVariant in your case. You might have to include <QVariant> as well.

    BTW: Inlining MJaoWidgetProperty::__render_function has no effect. The compiler needs to generate an address for the method to call it at runtime, so inlining it is out of the question.

  • thanks you very much, it works.

    Have you an idea why with g++ i have no problem to compile the exemple ?

  • QtConcurrent::run() is a static template method with a whole bunch of overloads (at least around 20 as far as i have seen). If you do not specify any template parameters, the compiler must try to find the correct template types based on the parameters you specified. In this case that is certainly no easy task for the compiler. MSVC is - as it seems - not able to implicitly find the right overload, but g++ can. The g++ implementation simply works better in this case.

  • ok thanks you very much.

Log in to reply