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. using QTConcurrent with qhash
Forum Update on Monday, May 27th 2025

using QTConcurrent with qhash

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 877 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.
  • A Offline
    A Offline
    abdullahzubair109
    wrote on last edited by abdullahzubair109
    #1

    beginner question : i have a QHash.. i am trying to call value method on it under QtConcurrent

    QFuture<const int> future = QtConcurrent::run(editorList, &QHash<QString, int>::value, key);
    

    compiler shows following error :

    /usr/include/x86_64-linux-gnu/qt5/QtConcurrent/qtconcurrentrunbase.h:90:7: error: uninitialized const member in ‘const int’ [-fpermissive]
     class RunFunctionTask : public RunFunctionTaskBase<T>
    
    

    i know i have to initialize const members.. but how??

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

      Hi,

      What exactly are you trying to accomplish with that QtConcurrent::run ?

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What exactly are you trying to accomplish with that QtConcurrent::run ?

        A Offline
        A Offline
        abdullahzubair109
        wrote on last edited by
        #3

        @SGaist i want to find out value from QHash using key..this function :
        https://doc.qt.io/qt-5/qhash.html#value

        A 1 Reply Last reply
        0
        • A abdullahzubair109

          @SGaist i want to find out value from QHash using key..this function :
          https://doc.qt.io/qt-5/qhash.html#value

          A Offline
          A Offline
          abdullahzubair109
          wrote on last edited by
          #4

          @abdullahzubair109 as the QHash is really large, so i was trying to run it in concurrent to prevent gui freezing

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

            May I suggest an alternative ?

            QFuture<int> future = QtConcurrent::run([=](){ return editorList.value(key); });

            On a side note, calling a hash editorList is pretty confusing.

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

            A 1 Reply Last reply
            1
            • SGaistS SGaist

              May I suggest an alternative ?

              QFuture<int> future = QtConcurrent::run([=](){ return editorList.value(key); });

              On a side note, calling a hash editorList is pretty confusing.

              A Offline
              A Offline
              abdullahzubair109
              wrote on last edited by
              #6

              @SGaist AFAIK lmbda are from c++ 11 .. I am using old c++ 98 .. One more thing : editorList records some QPlainTextEdit*

              A 1 Reply Last reply
              0
              • A abdullahzubair109

                @SGaist AFAIK lmbda are from c++ 11 .. I am using old c++ 98 .. One more thing : editorList records some QPlainTextEdit*

                A Offline
                A Offline
                abdullahzubair109
                wrote on last edited by abdullahzubair109
                #7

                @SGaist well I am convinced to name it something more representative

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

                  What version of Qt 5 are you using ?

                  This QtConcurrent::run(editorList, &QHash<QString, int>::value, key); basically mean that you want to run the QHash::value method on your editorList variable. There's some kind of issue with the logic here.

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

                  A 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    What version of Qt 5 are you using ?

                    This QtConcurrent::run(editorList, &QHash<QString, int>::value, key); basically mean that you want to run the QHash::value method on your editorList variable. There's some kind of issue with the logic here.

                    A Offline
                    A Offline
                    abdullahzubair109
                    wrote on last edited by
                    #9

                    @SGaist qt 5.5

                    A 1 Reply Last reply
                    0
                    • A abdullahzubair109

                      @SGaist qt 5.5

                      A Offline
                      A Offline
                      abdullahzubair109
                      wrote on last edited by
                      #10

                      @SGaist i had to use lambda finally.. so marking it solved.

                      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