Search code examples
c++qtcompiler-errorsqtconcurrent

QtConcurrent::run() can't handle more than 5 arguments?


I'm getting a compile error when passing a function with 6 parameters or more to QtConcurrent::run(). When I reduce them to 5 parameters, I no longer get this error.

This dummy code reproduces the error for me:

void foo(int, int, int, int, int, int)
{

}

QtConcurrent::run(foo, 1, 2, 3, 4, 5, 6);

The compiler error is:

error: no matching function for call to 'run(void (&)(int, int, int, int, int, int), int, int, int, int, int, int)'

Is this supposed to be so? Is QtConcurrent::run() really limited to 5 arguments at most?


Solution

  • See qtconcurrentrun.h

    template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
    QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5);
    

    There are 5 arguments that function can take