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. Unable to create QtConcurrent::run - Reference to non-static member function must be called
Forum Updated to NodeBB v4.3 + New Features

Unable to create QtConcurrent::run - Reference to non-static member function must be called

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 2.8k Views 1 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.
  • C Offline
    C Offline
    CoolSlimbo
    wrote on 26 Apr 2022, 09:40 last edited by
    #1

    Hello All,
    I wanna multithread my current project so it doesn't block my GUI and all. I'm relatively new to QT and Cpp as a whole but was wondering if anyone could help me with this.
    Qt Creator's suggestion to fix it involves adding brackets to the end, as shown, but results in an error saying No matching function for call to 'run'

    This is my code

    QFuture<void> future = QtConcurrent::run(log, test);
    

    And this is qt's suggested code

    QFuture<void> future = QtConcurrent::run(log(), test);
    

    All help is appreciated and, if possible, please explain something in the most simple of terms.

    If I'm using the wrong way to multithread, please inform me of a better way.

    J K 2 Replies Last reply 26 Apr 2022, 09:44
    0
    • C CoolSlimbo
      26 Apr 2022, 09:40

      Hello All,
      I wanna multithread my current project so it doesn't block my GUI and all. I'm relatively new to QT and Cpp as a whole but was wondering if anyone could help me with this.
      Qt Creator's suggestion to fix it involves adding brackets to the end, as shown, but results in an error saying No matching function for call to 'run'

      This is my code

      QFuture<void> future = QtConcurrent::run(log, test);
      

      And this is qt's suggested code

      QFuture<void> future = QtConcurrent::run(log(), test);
      

      All help is appreciated and, if possible, please explain something in the most simple of terms.

      If I'm using the wrong way to multithread, please inform me of a better way.

      J Offline
      J Offline
      JonB
      wrote on 26 Apr 2022, 09:44 last edited by JonB
      #2

      @CoolSlimbo
      Hello and welcome.

      Ignore the suggestion in this case, it's (doubtless) not what you are wanting!

      The issue is as reported by your title: "Reference to non-static member function must be called". So could you start by explaining (show declarations of) what your parameters log & test are?

      C 1 Reply Last reply 26 Apr 2022, 21:04
      0
      • C CoolSlimbo
        26 Apr 2022, 09:40

        Hello All,
        I wanna multithread my current project so it doesn't block my GUI and all. I'm relatively new to QT and Cpp as a whole but was wondering if anyone could help me with this.
        Qt Creator's suggestion to fix it involves adding brackets to the end, as shown, but results in an error saying No matching function for call to 'run'

        This is my code

        QFuture<void> future = QtConcurrent::run(log, test);
        

        And this is qt's suggested code

        QFuture<void> future = QtConcurrent::run(log(), test);
        

        All help is appreciated and, if possible, please explain something in the most simple of terms.

        If I'm using the wrong way to multithread, please inform me of a better way.

        K Offline
        K Offline
        KroMignon
        wrote on 26 Apr 2022, 10:13 last edited by
        #3

        @CoolSlimbo said in Unable to create QtConcurrent::run - Reference to non-static member function must be called:

        If I'm using the wrong way to multithread, please inform me of a better way.

        It depends what you really want to do!
        QtConcurrent::run() is an easy way to move a "heavy computing" code into another thread and to get result when done.
        So it is useful for "punctual" needs.

        You can also create a so called worker QObject based class which centralize all the computing, which will be triggered by slots (to start a new calculation / task) and generates signal when result(s) is/are ready.
        Then you can move the class instance to a thread to not "overload" the main thread (cf. https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/)

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

        S C 2 Replies Last reply 26 Apr 2022, 17:16
        0
        • K KroMignon
          26 Apr 2022, 10:13

          @CoolSlimbo said in Unable to create QtConcurrent::run - Reference to non-static member function must be called:

          If I'm using the wrong way to multithread, please inform me of a better way.

          It depends what you really want to do!
          QtConcurrent::run() is an easy way to move a "heavy computing" code into another thread and to get result when done.
          So it is useful for "punctual" needs.

          You can also create a so called worker QObject based class which centralize all the computing, which will be triggered by slots (to start a new calculation / task) and generates signal when result(s) is/are ready.
          Then you can move the class instance to a thread to not "overload" the main thread (cf. https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/)

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Apr 2022, 17:16 last edited by
          #4

          @KroMignon that blog post, while valid at that time can now be considered deprecated. The current QThread documentation covers the different possibilities very well and the folks at Woboq also provided follow up articles on that matter.

          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
          • J JonB
            26 Apr 2022, 09:44

            @CoolSlimbo
            Hello and welcome.

            Ignore the suggestion in this case, it's (doubtless) not what you are wanting!

            The issue is as reported by your title: "Reference to non-static member function must be called". So could you start by explaining (show declarations of) what your parameters log & test are?

            C Offline
            C Offline
            CoolSlimbo
            wrote on 26 Apr 2022, 21:04 last edited by
            #5

            @JonB The test parameter was for the function, which was just a QString for the function, and the actual log was a function that logs the infomation to a file. I'm trying to fix this, because everytime my app starts up it has a lil bit of lag. I have 2 other functions I plan to test it on that are of a slightly heavier load, one reading a text file and interpreting it, and another generating widgets for my ui.

            1 Reply Last reply
            0
            • K KroMignon
              26 Apr 2022, 10:13

              @CoolSlimbo said in Unable to create QtConcurrent::run - Reference to non-static member function must be called:

              If I'm using the wrong way to multithread, please inform me of a better way.

              It depends what you really want to do!
              QtConcurrent::run() is an easy way to move a "heavy computing" code into another thread and to get result when done.
              So it is useful for "punctual" needs.

              You can also create a so called worker QObject based class which centralize all the computing, which will be triggered by slots (to start a new calculation / task) and generates signal when result(s) is/are ready.
              Then you can move the class instance to a thread to not "overload" the main thread (cf. https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/)

              C Offline
              C Offline
              CoolSlimbo
              wrote on 27 Apr 2022, 08:25 last edited by
              #6

              @KroMignon Ignore what I'm using the QtConcurrent::run for. Just why do you think it's not working?

              J 1 Reply Last reply 27 Apr 2022, 08:26
              0
              • C CoolSlimbo
                27 Apr 2022, 08:25

                @KroMignon Ignore what I'm using the QtConcurrent::run for. Just why do you think it's not working?

                J Offline
                J Offline
                JonB
                wrote on 27 Apr 2022, 08:26 last edited by JonB
                #7

                @CoolSlimbo
                Your question was

                but results in an error saying No matching function for call to 'run'

                so how can we "ignore QtConcurrent::run()" if that is the problem?

                1 Reply Last reply
                0

                2/7

                26 Apr 2022, 09:44

                topic:navigator.unread, 5
                • Login

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