PDA

View Full Version : SOLVED::correct way to call a Mainwindow:: function() using QtConcurrent::run



alok9871
20th March 2013, 04:11
Hello

I need to run a MainWindow::function() using QtConcurrent run. I use the following code :

QFuture<void> newfuture = QtConcurrent::run(MainWindow::function);

I get the following error :




..\checkthread\mainwindow.cpp(12) : error C3867: 'MainWindow::newthread': function call missing argument list; use '&MainWindow::newthread' to create a pointer to member
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(Param1,Param2,Param3,Param4,Param5) const,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &)' : expects 7 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(334) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(Param1,Param2,Param3,Param4) const,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &)' : expects 6 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(329) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(Param1,Param2,Param3) const,const Arg1 &,const Arg2 &,const Arg3 &)' : expects 5 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(324) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(Param1,Param2) const,const Arg1 &,const Arg2 &)' : expects 4 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(319) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(Param1) const,const Arg1 &)' : expects 3 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(314) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class *,T (__thiscall Class::* )(void) const)' : expects 2 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(309) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(Param1,Param2,Param3,Param4,Param5),const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &)' : expects 7 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(303) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(Param1,Param2,Param3,Param4),const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &)' : expects 6 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(298) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(Param1,Param2,Param3),const Arg1 &,const Arg2 &,const Arg3 &)' : expects 5 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(293) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(Param1,Param2),const Arg1 &,const Arg2 &)' : expects 4 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(288) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(Param1),const Arg1 &)' : expects 3 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(283) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(Class *,T (__thiscall Class::* )(void))' : expects 2 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(278) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3,Param4,Param5) const,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &)' : expects 7 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(272) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3,Param4) const,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &)' : expects 6 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(267) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3) const,const Arg1 &,const Arg2 &,const Arg3 &)' : expects 5 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(262) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2) const,const Arg1 &,const Arg2 &)' : expects 4 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(257) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1) const,const Arg1 &)' : expects 3 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(252) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(void) const)' : expects 2 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(247) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3,Param4,Param5),const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &)' : expects 7 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(241) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3,Param4),const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &)' : expects 6 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(236) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2,Param3),const Arg1 &,const Arg2 &,const Arg3 &)' : expects 5 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(231) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1,Param2),const Arg1 &,const Arg2 &)' : expects 4 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(226) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(Param1),const Arg1 &)' : expects 3 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(221) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<T> QtConcurrent::run(const Class &,T (__thiscall Class::* )(void))' : expects 2 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(216) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<FunctionObject::result_type> QtConcurrent::run(FunctionObject *,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &)' : expects 6 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(210) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<FunctionObject::result_type> QtConcurrent::run(FunctionObject *,const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &)' : expects 5 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(205) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<FunctionObject::result_type> QtConcurrent::run(FunctionObject *,const Arg1 &,const Arg2 &)' : expects 3 arguments - 1 provided
c:\qt\4.8.4\include\qtcore\../../src/corelib/concurrent/qtconcurrentrun.h(195) : see declaration of 'QtConcurrent::run'
..\checkthread\mainwindow.cpp(12) : error C2780: 'QFuture<FunctionObject::result_type> QtConcurrent::run(FunctionObject *,const Arg1 &)' : expects 2 arguments - 1 provided



Can you tell me the right way to call this function using QtConcurrent

ChrisW67
20th March 2013, 04:33
Member functions need to be passed their implied "this" pointer argument. QtConcurrent::run() has an option for this that is described, with examples, in the documentation under "Using Member Functions"

alok9871
20th March 2013, 05:37
Thanks You Very Much!!!
Problem Solved

It should be :

QFuture<void> newfuture = QtConcurrent::run(this,&MainWindow::function);