Results 1 to 2 of 2

Thread: Error in compilation using methods in QtConcurrent

  1. #1
    Join Date
    Mar 2009
    Location
    Va, Spain
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Error in compilation using methods in QtConcurrent

    I'm trying to use QtConcurrent::map to concurrently run a image conversion on each of the selected files that the user inputs to my app. For this I have a class that gets all the info about where the file will be stored and other stuff, and I have two methods for the conversion:

    void ConvertThread::convert()
    void ConvertThread::convertFileToPdf(const QString& file)

    In the convert method, I set a QFuture<void> f = QtConcurrent::map(fileList, &ConvertThread::convertFileToPdf), where fileList is a QList<String>

    I've been using code from Qt examples on how to do this and I think I got it right, but for some reason when I try to compile I'm getting this error:

    /Library/Frameworks/QtCore.framework/Headers/qtconcurrentmapkernel.h: In member function 'bool QtConcurrent::MapKernel<Iterator, MapFunctor>::runIteration(Iterator, int, void*) [with Iterator = QList<QString>::iterator, MapFunctor = void (ConvertThread::*)(const QString&)]':
    convertthread.cpp:39: instantiated from here
    /Library/Frameworks/QtCore.framework/Headers/qtconcurrentmapkernel.h:73: error: must use '.*' or '->*' to call pointer-to-member function in '((QtConcurrent::MapKernel<QList<QString>::iterato r, void (ConvertThread::*)(const QString&)>*)this)->QtConcurrent::MapKernel<QList<QString>::iterato r, void (ConvertThread::*)(const QString&)>::map (...)'
    make[1]: *** [debug/convertthread.o] Error 1

    If anyone has experience with using QtConcurrent this way, I'd really appreciate some help here.

    ps: I know some of the other code isn't connected yet

    convertthread.cpp:
    Qt Code:
    1. #include "convertthread.h"
    2. #include <Magick++.h>
    3.  
    4. using namespace Magick;
    5.  
    6. void ConvertThread::enqueueFile(const QString& path) {
    7. fileList << path;
    8. }
    9.  
    10. void ConvertThread::convert() {
    11. QFuture<void> f = QtConcurrent::map(fileList, &ConvertThread::convertFileToPdf);
    12. converter->setFuture(f);
    13. }
    14.  
    15. void ConvertThread::sendFinishedSignal() {
    16. emit imageStatus();
    17. }
    18.  
    19. void ConvertThread::setOutputDir(const QString& folder) {
    20. destFolder = folder;
    21. }
    22.  
    23. void ConvertThread::convertFileToPdf(const QString& file) {
    24. QString outPath;
    25. QFileInfo *info = new QFileInfo(file);
    26. QString fileName = info->baseName();
    27. outPath = destFolder + QDir::separator() + fileName + ".pdf";
    28. delete info;
    29.  
    30. Image *image = new Image();
    31. try {
    32. image->read(qPrintable(file));
    33. image->magick("PDF");
    34. image->write(qPrintable(outPath));
    35. }
    36. catch(Exception &error_) {
    37. return;
    38. }
    39. delete image;
    40. }
    To copy to clipboard, switch view to plain text mode 

    convertthread.h:
    Qt Code:
    1. #ifndef CONVERTTHREAD_H
    2. #define CONVERTTHREAD_H
    3.  
    4. #include <QObject>
    5. #include <QtGui>
    6. #include <QFuture>
    7. #include <QFutureWatcher>
    8.  
    9. class ConvertThread : public QObject
    10. {
    11. Q_OBJECT
    12. public:
    13. ConvertThread() {
    14. converter = new QFutureWatcher<void>(this);
    15. connect(converter, SIGNAL(resultReadyAt(int)), SLOT(sendFinishedSignal()));
    16. }
    17. ~ConvertThread() {
    18. converter->cancel();
    19. converter->waitForFinished();
    20. }
    21. void convert();
    22. void enqueueFile(const QString& path);
    23. void setOutputDir(const QString& folder);
    24. void convertFileToPdf(const QString& file);
    25.  
    26. private:
    27. QFutureWatcher<void> *converter;
    28. QList<QString> fileList;
    29. QString destFolder;
    30.  
    31. signals:
    32. void imageStatus();
    33.  
    34. public slots:
    35. void sendFinishedSignal();
    36. };
    37.  
    38. #endif // CONVERTTHREAD_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2010
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Error in compilation using methods in QtConcurrent

    I have the exact same problem and can't seem to figure out why it won't compile.

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.