Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems with Qt Concurrent mapped

Problems with Qt Concurrent mapped

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fordem
    wrote on last edited by
    #1

    I've been trying to create a simple image processing procedure where i have a list of images that needs to be written to the disk and trimmed so here is the code for this function
    @
    static int i=0;
    void writeRenderingImage(const QImage &q){

    QString path(QDir::currentPath().append("/moviePictures"));
    QString p(path);
    p.append(QString("/photo%1.png").arg(i++,5,10,QChar('0')));
    std::cout<<p.toStdString()<<"\n";
    q.save(p,"PNG",10);
    QString trimCommand("convert -trim ");
    trimCommand.append(p).append(" ").append(p);
    system&#40;trimCommand.toStdString(&#41;.c_str(&#41;&#41;;
    

    }
    @
    Since i have this function i have another function wich calls this procedure through the QtConcurrent::mapped utility
    @
    void GraphPrincipal::createMovieAction() {
    i=0;
    QString path(QDir::currentPath().append("/moviePictures"));
    QString command("rm -rf ");
    command.append(path).append("/*.png");
    system(command.toStdString().c_str());

    QProgressDialog dialog;
    dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
    QFutureWatcher<void> futureWatcher;
    connect(&futureWatcher;, SIGNAL(finished()), &dialog;, SLOT(reset()));
    connect(&dialog;, SIGNAL(canceled()), &futureWatcher;, SLOT(cancel()));
    connect(&futureWatcher;, SIGNAL(progressRangeChanged(int, int)), &dialog;, SLOT(setRange(int, int)));
    connect(&futureWatcher;, SIGNAL(progressValueChanged(int)), &dialog;, SLOT(setValue(int)));
    

    //gsw->getRenderingImages() returns a QList<Qimage> object
    QFuture<void> qv=QtConcurrent::mapped(gsw->getRenderingImages(),writeRenderingImage);
    futureWatcher.setFuture(qv);
    dialog.exec();
    futureWatcher.waitForFinished();
    }
    @

    So When i try to run this code i get the following error.
    @
    /usr/include/qt4/QtCore/qtconcurrentmapkernel.h: In member function ‘bool QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::runIteration(Iterator, int, QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::T*) [with Iterator = QList<QImage>::const_iterator, MapFunctor = QtConcurrent::FunctionWrapper1<void, const QImage&>, QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::T = void]’:
    In file included from /usr/include/qt4/QtCore/qtconcurrentfilterkernel.h:50:0,
    from /usr/include/qt4/QtCore/qtconcurrentfilter.h:49,
    from /usr/include/qt4/QtCore/QtCore:92,
    from /usr/include/qt4/QtGui/QtGui:3,
    from GraphPrincipal.h:10,
    from GraphPrincipal.cpp:7:
    GraphPrincipal.cpp:146:1: instantiated from here
    /usr/include/qt4/QtCore/qtconcurrentmapkernel.h:180:9: error: ‘QtConcurrent::MappedEachKernel<QList<QImage>::const_iterator<QImage>, QtConcurrent::FunctionWrapper1<void, const QImage&> >::T*’ is not a pointer-to-object type
    /usr/include/qt4/QtCore/qtconcurrentmapkernel.h: In member function ‘bool QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::runIterations(Iterator, int, int, QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::T*) [with Iterator = QList<QImage>::const_iterator, MapFunctor = QtConcurrent::FunctionWrapper1<void, const QImage&>, QtConcurrent::MappedEachKernel<Iterator, MapFunctor>::T = void]’:
    @

    Can some1 tell me what i'm doing wrong i've been reading all the docs i can but can't find no solution. if some1 could help, plz... do it so.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      Ok as far as I understand the source code and the error provided by you the problem resides in this line of code:

      @
      QFuture<void> qv=QtConcurrent::mapped(gsw->getRenderingImages(),writeRenderingImage);
      @

      Its just a guess but I think the two parameters don't fit. As I understand from the compiler error the @gsw->getRenderingImages()@ returns an iterator of type @QList<QImage>::const_iterator<QImage>@ and writeRenderingImage() expects a const reference to an image.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fordem
        wrote on last edited by
        #3

        i Thank u for your answer, but i solved it using pthread instead. I start one thread per picture to work on, than use pthread_join to track the progress of the work being done. Thanks for the answer anyway.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved