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
QtWS25 Last Chance

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.7k 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
    CoolSlimbo
    wrote on 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.

    JonBJ KroMignonK 2 Replies Last reply
    0
    • C CoolSlimbo

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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
      0
      • C CoolSlimbo

        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.

        KroMignonK Offline
        KroMignonK Offline
        KroMignon
        wrote on 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)

        SGaistS C 2 Replies Last reply
        0
        • KroMignonK KroMignon

          @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/)

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          • JonBJ JonB

            @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 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
            • KroMignonK KroMignon

              @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 last edited by
              #6

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

              JonBJ 1 Reply Last reply
              0
              • C CoolSlimbo

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

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on 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

                • Login

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