Results 1 to 2 of 2

Thread: Problem using QtConcurrent with members fuctions

  1. #1
    Join Date
    Feb 2010
    Location
    Cuba
    Posts
    35
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Problem using QtConcurrent with members fuctions

    Hello every one!
    I'm using QtConcurrent to load a file in other thread:

    Qt Code:
    1. struct tipoRegistro {
    2. qint16 val1;
    3. qint16 val2 ;
    4. qint16 val3;
    5. };
    6.  
    7. tipoRegistro MainWindow::readFileStepByStep()
    8. {
    9. file.read(reinterpret_cast<char*> (&reg),sizeof(tipoRegistro));
    10. return reg;
    11. }
    12.  
    13. void MainWindow::qtConcurrentTest()
    14. {
    15. QVector<tipoRegistro> vector;
    16. tipoRegistro treg;
    17. treg.val1 = -1;
    18. treg.val2 = -1;
    19. treg.val3 = -1;
    20. for(int i = 0; i < num_muestras_canal; i++)
    21. vector.append(treg);
    22.  
    23. dialog.setLabelText(QString("Cargando archivo ECG"));
    24.  
    25. QFutureWatcher<void> futureWatcher;
    26. QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
    27. QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
    28. QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
    29. QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
    30.  
    31. futureWatcher.setFuture(QtConcurrent::mapped(vector,readFileStepByStep));
    32.  
    33. dialog.exec();
    34.  
    35. futureWatcher.waitForFinished();
    36. }
    To copy to clipboard, switch view to plain text mode 

    I get the fallowing error:
    ../ECGReader/mainwindow.cpp: In member function 'void MainWindow::qtConcurrentTest()':
    ../ECGReader/mainwindow.cpp:264:75: error: no matching function for call to 'mapped(QVector<tipoRegistro>&, <unresolved overloaded function type>)'
    ../ECGReader/mainwindow.cpp:264:75: note: candidates are:
    /usr/include/qt4/QtCore/qtconcurrentmap.h:181:74: note: QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(const Sequence&, MapFunctor) [with Sequence = QVector<tipoRegistro>, MapFunctor = tipoRegistro (MainWindow::*)(), typename QtPrivate::MapResultType<void, MapFunctor>::ResultType = void]
    /usr/include/qt4/QtCore/qtconcurrentmap.h:181:74: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'tipoRegistro (MainWindow::*)()'
    /usr/include/qt4/QtCore/qtconcurrentmap.h:188:74: note: template<class Iterator, class MapFunctor> QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(Iterator, Iterator, MapFunctor)
    I think the problem can be using members fuction, but i tried modifying the line tis way:

    futureWatcher.setFuture(QtConcurrent::mapped(vecto r, &MainWindow::readFileStepByStep));
    but I keep getting errors

    If anyone can help...thanks in advanced.
    Regards.

    pd: Sorry my english

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem using QtConcurrent with members fuctions

    If you had searched you would have found this:
    http://www.qtcentre.org/threads/3228...unction-member

    It suggests lookling here... http://doc.qt.digia.com/4.6/qtconcurrentrun.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 1
    Last Post: 5th April 2012, 08:17
  2. problem with QtConcurrent::run
    By etognoni in forum Newbie
    Replies: 2
    Last Post: 5th April 2012, 00:14
  3. Problem with QtConcurrent::run
    By januszmk in forum Newbie
    Replies: 5
    Last Post: 30th July 2011, 18:57
  4. Replies: 4
    Last Post: 14th January 2010, 17:30
  5. qt designer:linking fuctions to actions?
    By switch in forum Qt Tools
    Replies: 1
    Last Post: 26th July 2009, 15:48

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.