Results 1 to 3 of 3

Thread: SOLVED::correct way to call a Mainwindow:: function() using QtConcurrent::run

  1. #1
    Join Date
    Dec 2012
    Posts
    17
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default SOLVED::correct way to call a Mainwindow:: function() using QtConcurrent::run

    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
    Last edited by alok9871; 20th March 2013 at 05:38. Reason: Problem Solved

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: correct way to call a Mainwindow:: function() using QtConcurrent::run

    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"

  3. The following user says thank you to ChrisW67 for this useful post:

    alok9871 (20th March 2013)

  4. #3
    Join Date
    Dec 2012
    Posts
    17
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: correct way to call a Mainwindow:: function() using QtConcurrent::run

    Thanks You Very Much!!!
    Problem Solved

    It should be :

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

  5. The following user says thank you to alok9871 for this useful post:

    Isma (5th April 2013)

Similar Threads

  1. Replies: 11
    Last Post: 20th February 2013, 15:54
  2. Replies: 11
    Last Post: 5th September 2012, 20:47
  3. Replies: 4
    Last Post: 2nd August 2012, 07:42
  4. Replies: 1
    Last Post: 12th April 2011, 09:53
  5. QtConcurrent::run() with function member?
    By wookoon in forum Newbie
    Replies: 3
    Last Post: 8th July 2010, 13:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.