Results 1 to 2 of 2

Thread: Problem with QtConcurrent::map arguments

  1. #1
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Problem with QtConcurrent::map arguments

    I'm trying to use QtConcurrent::map to run this function

    Qt Code:
    1. //This function is used through QtConcurrent::map to create images from a QString path
    2. void MainWindow::createQImage(QString* path) {
    3. //create an image from the given path
    4. QImage* t = new QImage(*path);
    5. imageList->append(t);
    6. }
    To copy to clipboard, switch view to plain text mode 

    on this container (declared in the mainwindow header and initialized in the mainwindow constructor)

    Qt Code:
    1. QList<QImage *> *imageList = new QList<QImage *>;
    To copy to clipboard, switch view to plain text mode 

    Here's the code I'm trying to run

    Qt Code:
    1. QFutureWatcher<void> futureWatcher;
    2. futureWatcher.setFuture(QtConcurrent::map(imageList, &MainWindow::createQImage));
    To copy to clipboard, switch view to plain text mode 

    and here's the error I'm getting:

    request for member 'begin' in 'sequence', which is of non-class type 'QList<QImage*>*'
    request for member 'end' in 'sequence', which is of non-class type 'QList<QImage*>*'
    I believe the problem to be with the first parameter to the map function. And from what I've read, it may have to do with compatibility. There isn't much sample code online that I was able to relate to. I'm new to Qt and not the most experienced of programmers but I'd appreciate some help and feedback.
    Last edited by jalm; 5th April 2012 at 11:13. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem with QtConcurrent::map arguments

    create a function which returns the image, then an additional slot connected to the ready signal of the future watcher. In that add the image to the imageList. Otherwise you have to lock/protect imageList in the createQImage function because of the used thread.

Similar Threads

  1. problem with QtConcurrent::run
    By etognoni in forum Newbie
    Replies: 2
    Last Post: 4th April 2012, 23:14
  2. setHtml and QtConcurrent problem
    By andrepimenta in forum Qt Programming
    Replies: 1
    Last Post: 1st January 2012, 20:06
  3. Problem with QtConcurrent::run
    By januszmk in forum Newbie
    Replies: 5
    Last Post: 30th July 2011, 17:57
  4. qtconcurrent
    By knishaq in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2009, 08:41
  5. QMap Problem with arguments.
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 12: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.