Results 1 to 6 of 6

Thread: QtConcurrent, Unresolved Overloaded Function Type

  1. #1
    Join Date
    Nov 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QtConcurrent, Unresolved Overloaded Function Type

    Hey everyone,

    I'm trying to incorportate QtConcurrent into one of my classes, and I'm starting simple with it:

    Qt Code:
    1. #include "coredata.h"
    2.  
    3. CoreData::CoreData()
    4. {
    5.  
    6. }
    7.  
    8. void CoreData::afunc()
    9. {
    10.  
    11. }
    12.  
    13. void CoreData::threaded()
    14. {
    15. QFuture<void> future = QtConcurrent::run(afunc);
    16. }
    To copy to clipboard, switch view to plain text mode 

    This results in an error:
    error: no matching function for call to 'run(<unresolved overloaded function type>)'

    I've looked through the Qt Documentation, and since it is all within the main() function, I don't know how it works within a class. I have a feeling I'm missing something simple, but I'm relatively new to C++ and the solution is escaping me.

    Thanks in advance!!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtConcurrent, Unresolved Overloaded Function Type

    You don't have a "afunc" function. You only have a CoreData::afunc method.

    Qt Code:
    1. QFuture<void> future = QtConcurrent::run(this, &CoreData::afunc);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QtConcurrent, Unresolved Overloaded Function Type

    Thank you for the help; I implemented that in my code and it works great. However, after looking through the documentation I believe the QtConcurrent::map would be better since it allows control over the timing, which I need.

    I have a vector "idxvec" that has n elements, going from 0 to n. I'd like to implement the function like this:

    Qt Code:
    1. vector<qint32> idxvec(nregions);
    2.  
    3. for (idx = 0; idx < nregions; idx++)
    4. idxvec[idx] = idx;
    5.  
    6. QtConcurrent::map(idxvec,this,&CoreData::runCorrelation);
    To copy to clipboard, switch view to plain text mode 

    However this doesn't compile. I apologize for all these questions, the documentation is really sparse about this

    Thanks!

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QtConcurrent, Unresolved Overloaded Function Type

    The prototype of the function you want to use is:

    QFuture<void> QtConcurrent::map ( Iterator begin, Iterator end, MapFunction function )
    As you can see, using "this" for "Iterator end" does not work, neither does the first parameter work.

  5. #5
    Join Date
    Nov 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QtConcurrent, Unresolved Overloaded Function Type

    I'm trying to implement that prototype, however the problem I'm having is that I cannot use my class method CoreData::runCorrelation as the function. Do I need to use boost::bind to attach the class method to the this pointer?

    Thanks,

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtConcurrent, Unresolved Overloaded Function Type

    Can you make your runCorrelation method static? If yes then do so.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Mac OSX: QList<(type)>::detach_detach.* coming up unresolved.
    By rickbsgu in forum Installation and Deployment
    Replies: 0
    Last Post: 1st September 2010, 18:27
  2. QDirModel's index overloaded function
    By psih128 in forum Qt Programming
    Replies: 1
    Last Post: 31st December 2009, 07:11
  3. QImage::bits() overloaded function
    By s410i in forum Qt Programming
    Replies: 3
    Last Post: 9th December 2009, 19:50
  4. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26
  5. ambiguous call to overloaded function
    By :db:sStrong in forum Qt Programming
    Replies: 18
    Last Post: 10th February 2006, 09:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.