Results 1 to 6 of 6

Thread: QtConcurrent Questions and Clarifications

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    39
    Thanks
    15
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QtConcurrent Questions and Clarifications

    Hi all experienced types,
    I have a couple of questions about using QtConcurrent. So I spent days and days just trying to get something to actually run in another thread (not a simple QImage example - so sick of seeing those) but one where I needed a member function from one of my own classes. A have read and read various posts, articles, TFM etc and find it very esoteric to be be truthful. I am not bagging the various sources just my lack of C++ and Qt experience. So firstly,

    1) if I instantiate and object in my code;
    Qt Code:
    1. SomeClass *myClass = new SomeClass(arg1, arg2,..,this)
    To copy to clipboard, switch view to plain text mode 
    and then use QtConcurrent to start a trhead;
    Qt Code:
    1. QFuture<T> = QtConcurrent::run(myClass,&SomeClass::myFunction, newarg1, newarg2)
    To copy to clipboard, switch view to plain text mode 
    for example. Is QtConcurrent::run using the myClass object internal variables when it runs myFunction (and assuming myFunction requires these but not through the call to the function)? e.g. I have a private variable arg1 which was set in the constructor and which myFunction uses as well.

    2) If I want to use QtConcurrent::mapped (which still fails me, and yes the documentation I am sure is fantastic but confusing to me) is the only way for me to get it to use a function that has multiple arguments to use boost::bind or the other suggested one? Otherwise it seems, and correct me if I am wrong, that I am only able to run a function that ever takes a singular input (which seems really, really limiting) EDIT: found this link on the wiki but not really what I was after[WIKI]http://developer.qt.nokia.com/wiki/QtConcurrent-BlockingMapped-Other-Object-Member-Function-Operator[/WIKI]

    3) Can anyone tell me what the error message here is referring to. I suspect its something simple but I don't understand what it is that I have done wrong;
    C:\Qt_projects\DrillDown\DrillDown\feature_finder. cpp:582: error: C2679: binary '=' : no operator found which takes a right-hand operand of type 'QFuture<void>' (or there is no acceptable conversion)
    c:\qtsdk\desktop\qt\4.8.1\msvc2010\include\qtcore\ qvector.h(125): could be 'QVector<T> &QVector<T>:perator =(const QVector<T> &)'
    with
    [
    T=QVector<QVector<QVector<double>>>
    ]
    c:\qtsdk\desktop\qt\4.8.1\msvc2010\include\qtcore\ qvector.h(127): or 'QVector<T> QVector<T>:perator =(QVector<T> &&)'
    with
    [
    T=QVector<QVector<QVector<double>>>
    ]
    while trying to match the argument list '(QVector<T>, QFuture<void>)'
    with
    [
    T=QVector<QVector<QVector<double>>>
    ]
    The offending line of code is below and is called (or not in this case) in a member function of the feature_finder class. Extraction is also a member function of feature_finder, albeit one I have had to try and tweak down to a singular input argument.
    Qt Code:
    1. QVector<QVector<QVector<QVector<double> > > > future;
    2. future = QtConcurrent::mapped(spectrain,&feature_finder::Extraction);
    To copy to clipboard, switch view to plain text mode 
    I am more interested in knowing if anyone has seen the same error can let me know what it means (I understand that it is saying that the right hand side returns a future<void> but why?
    I have tried what seems like a million variants on the above usage and f&*ked if I can get it to work in any capacity what so ever (go easy on me I am a NOOB)

    Cheers
    Oz
    Last edited by OzQTNoob; 22nd November 2012 at 02:56.

Similar Threads

  1. QtConcurrent: clarifications needed
    By papillon in forum Qt Programming
    Replies: 5
    Last Post: 28th April 2012, 17:17
  2. QtConcurrent, i need advice
    By SABROG in forum Qt Programming
    Replies: 10
    Last Post: 29th December 2009, 19:53
  3. Why is QtConcurrent so slow?
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 10
    Last Post: 29th December 2009, 10:37
  4. qtconcurrent
    By knishaq in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2009, 08:41
  5. QtConcurrent
    By Brandybuck in forum An Introduction to QThreads
    Replies: 2
    Last Post: 9th May 2008, 14:10

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.