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. A concurrent function run problem.
Forum Updated to NodeBB v4.3 + New Features

A concurrent function run problem.

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 509 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.
  • J Offline
    J Offline
    jenya7
    wrote on last edited by jenya7
    #1

    I try to run a function.

    void SENSOR::DiscoverConcurrent(uint32_t count)
    {
            QFuture<void> future = QtConcurrent::run(SENSOR::DiscoverByIndexAll,  count);
    }
    

    But I get this error - error: reference to non-static member function must be called.
    What does it means. The function

    void SENSOR::DiscoverByIndexAll(uint32_t count)
    {]
    

    Is not static - I can call it from other modules.

    J.HilkJ 1 Reply Last reply
    0
    • J jenya7

      I try to run a function.

      void SENSOR::DiscoverConcurrent(uint32_t count)
      {
              QFuture<void> future = QtConcurrent::run(SENSOR::DiscoverByIndexAll,  count);
      }
      

      But I get this error - error: reference to non-static member function must be called.
      What does it means. The function

      void SENSOR::DiscoverByIndexAll(uint32_t count)
      {]
      

      Is not static - I can call it from other modules.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @jenya7 said in A concurrent function run problem.:

      Is not static - I can call it from other modules.

      right its not static, therefore it requires an instance pointer. this in this case


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      J 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        @jenya7 said in A concurrent function run problem.:

        Is not static - I can call it from other modules.

        right its not static, therefore it requires an instance pointer. this in this case

        J Offline
        J Offline
        jenya7
        wrote on last edited by jenya7
        #3

        @J-Hilk

        void SENSOR::DiscoverConcurrent(uint32_t count)
        {
            QFuture<void> future = QtConcurrent::run(this->DiscoverByIndexAll, count);
        }
        

        the same error

        J.HilkJ 1 Reply Last reply
        0
        • J jenya7

          @J-Hilk

          void SENSOR::DiscoverConcurrent(uint32_t count)
          {
              QFuture<void> future = QtConcurrent::run(this->DiscoverByIndexAll, count);
          }
          

          the same error

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @jenya7

          QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll,  count);
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          J JKSHJ 2 Replies Last reply
          4
          • J.HilkJ J.Hilk

            @jenya7

            QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll,  count);
            
            J Offline
            J Offline
            jenya7
            wrote on last edited by
            #5

            @J-Hilk said in A concurent function run problem.:

            this, &SENSOR::DiscoverByIndexAll, count

            Thank you. And how can I call the function concurrently from other module?

            jsulmJ 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @jenya7

              QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll,  count);
              
              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @J-Hilk said in A concurrent function run problem.:

              QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll,  count);
              

              @J-Hilk is right. This is documented at https://doc.qt.io/qt-5/qtconcurrentrun.html#using-member-functions

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              4
              • J jenya7

                @J-Hilk said in A concurent function run problem.:

                this, &SENSOR::DiscoverByIndexAll, count

                Thank you. And how can I call the function concurrently from other module?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @jenya7 said in A concurrent function run problem.:

                And how can I call the function concurrently from other module?

                In the same way, just pass pointer to SENSOR instance instead of this...

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                J 1 Reply Last reply
                3
                • jsulmJ jsulm

                  @jenya7 said in A concurrent function run problem.:

                  And how can I call the function concurrently from other module?

                  In the same way, just pass pointer to SENSOR instance instead of this...

                  J Offline
                  J Offline
                  jenya7
                  wrote on last edited by
                  #8

                  @jsulm
                  Thank you. Now it works good. No GUI blocking.

                  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