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. How to use QtConcurrent::functions and what is my error?
QtWS25 Last Chance

How to use QtConcurrent::functions and what is my error?

Scheduled Pinned Locked Moved Solved General and Desktop
concurrentmapqtconcurrent
2 Posts 2 Posters 354 Views
  • 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.
  • C Offline
    C Offline
    CuriousPan
    wrote on last edited by
    #1

    Hello everyone!
    I have a list of strings and I want to process them in parallel performing some actions on them. However, when I try to build my code, I have an error stating that the desired function cannot be called. What is my problem?

    Here's the code I'd like to run:

    QStringList filePaths;
    
    QString Controller::action(QString& str)
    {
        // make some actions on files
        return str; // I don't really care about the return value.
    }
    
    QtConcurrent::map(filePaths, &Controller::action);
    

    When I try to build my code I get a following error:

    C:\Qt\5.15.2\mingw81_64\include\QtConcurrent\qtconcurrentmap.h:49: In file included from C:/Qt/5.15.2/mingw81_64/include/QtConcurrent/qtconcurrentmap.h:49,
    In file included from C:/Qt/5.15.2/mingw81_64/include/QtConcurrent/qtconcurrentmap.h:49,
                     from C:/Qt/5.15.2/mingw81_64/include/QtConcurrent/QtConcurrentMap:1,
                     from C:/copyrightadder/src/Controllers/Controller.cpp:10:
    C:/Qt/5.15.2/mingw81_64/include/QtConcurrent/qtconcurrentfunctionwrappers.h:132:14: note: candidate: 'T QtConcurrent::MemberFunctionWrapper1<T, C, U>::operator()(C&, U) [with T = QString; C = Controller; U = QString&]'
         inline T operator()(C &c, U u)
                  ^~~~~~~~
    C:/Qt/5.15.2/mingw81_64/include/QtConcurrent/qtconcurrentfunctionwrappers.h:132:14: note:   candidate expects 2 arguments, 1 provided
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you want to use a member function, the array you pass to the map method must contain items of that class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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