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. QtConcurrent::BlockingMap using member functions (with an argument) without C++11 or boost

QtConcurrent::BlockingMap using member functions (with an argument) without C++11 or boost

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 720 Views 2 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.
  • K Offline
    K Offline
    kamui
    wrote on last edited by
    #1

    Hello,

    How to do the exact same thing without C++11 (or boost) ?

     QtConcurrent::BlockingMap(fileinfolist, [=](QFileInfo fi){
            myMemberFunction(fi);
    }
    
    KroMignonK 1 Reply Last reply
    0
    • K kamui

      Hello,

      How to do the exact same thing without C++11 (or boost) ?

       QtConcurrent::BlockingMap(fileinfolist, [=](QFileInfo fi){
              myMemberFunction(fi);
      }
      
      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @kamui said in QtConcurrent::BlockingMap using member functions (with an argument) without C++11 or boost:

      How to do the exact same thing without C++11 (or boost) ?

      If don't want to use lambda function, declare a local function and call it with QtConcurrent::BlockingMap ==> https://doc.qt.io/qt-5/qtconcurrentmap.html#concurrent-map

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      3
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Note that if you use a version of Qt that is 5.7 or more recent, C++11 is mandatory to have so you can go on with lambdas.

        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
        1
        • K Offline
          K Offline
          kamui
          wrote on last edited by kamui
          #4

          Sadly it's for a version of the app still running on 5.5 ...

          And I can't manage to make it work with something like this :

          QtConcurrent::BlockingMap(fileinfolist, &MyClass::MyMemberFunction);
          

          because myMemberFunction expects an arguement (other than this)

          KroMignonK 1 Reply Last reply
          0
          • K kamui

            Sadly it's for a version of the app still running on 5.5 ...

            And I can't manage to make it work with something like this :

            QtConcurrent::BlockingMap(fileinfolist, &MyClass::MyMemberFunction);
            

            because myMemberFunction expects an arguement (other than this)

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #5

            @kamui Have you tried?

            QtConcurrent::BlockingMap(fileinfolist, this, &MyClass::MyMemberFunction);
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kamui
              wrote on last edited by
              #6

              Yes I tried it, because of the compiler message error :

              QtConcurrent::BlockingMap(fileinfolist, &MyClass::MyMemberFunction);

              f66f59b5-6a5a-4913-8adc-aa64c223de06-image.png

              QtConcurrent::BlockingMap(fileinfolist, this, &MyClass::MyMemberFunction);

              ba8764e0-8922-4765-b701-7768766e8753-image.png

              As you can see, I can't have the good amount of arguments xD

              KroMignonK 1 Reply Last reply
              0
              • K kamui

                Yes I tried it, because of the compiler message error :

                QtConcurrent::BlockingMap(fileinfolist, &MyClass::MyMemberFunction);

                f66f59b5-6a5a-4913-8adc-aa64c223de06-image.png

                QtConcurrent::BlockingMap(fileinfolist, this, &MyClass::MyMemberFunction);

                ba8764e0-8922-4765-b701-7768766e8753-image.png

                As you can see, I can't have the good amount of arguments xD

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by KroMignon
                #7

                @kamui I apologize, I wrote something stupid, this cannot work!

                You have to define a function to be called with each of the element from the sequence:

                
                void myMapFunction(const QFileInfo &fi)
                {
                  /// do stuff
                }
                ...
                QtConcurrent::blockingMap(fileinfolist, myMapFunction);
                

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                1 Reply Last reply
                2
                • K Offline
                  K Offline
                  kamui
                  wrote on last edited by kamui
                  #8

                  Thank you for the help but my question was "using member functions". I saw the documentation before asking

                  Nevermind In fact I manipulate a tree (QAbstractModelItem & co) inside and it appeared to be non thread-safe so ...

                  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