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. Running a member function in a QtConcurrent thread
Forum Updated to NodeBB v4.3 + New Features

Running a member function in a QtConcurrent thread

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 527 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.
  • D Offline
    D Offline
    dwilliams
    wrote on last edited by
    #1

    I have a member function that runs to call a device SDK. It works, but I need to run it in a thread.

    //Working method:
    void DtXrayDetector::startDeviceAcquisition(QString debugID) {
        writeDebugLogEntryWithMutex("DtxRayDetector::startDeviceAcquistions for " + debugID);
    
        _dt.xAcq->Snap();
    }
    
    //Desired method:
    void DtXrayDetector::startDeviceAcquisition(QString debugID) {
        writeDebugLogEntryWithMutex("DtxRayDetector::startDeviceAcquistions for " + debugID);
        QFuture<void> qf;
        qf = QtConcurrent::run(_dt.xAcq->Snap());
    
    }
    

    I get an error: No matching function for call to run.

    I'm guessing this is a syntax issue that I just don't understand. I've tried a couple of variations that haven't worked. Do you see what I need to do differently?

    KroMignonK 1 Reply Last reply
    0
    • D dwilliams

      I have a member function that runs to call a device SDK. It works, but I need to run it in a thread.

      //Working method:
      void DtXrayDetector::startDeviceAcquisition(QString debugID) {
          writeDebugLogEntryWithMutex("DtxRayDetector::startDeviceAcquistions for " + debugID);
      
          _dt.xAcq->Snap();
      }
      
      //Desired method:
      void DtXrayDetector::startDeviceAcquisition(QString debugID) {
          writeDebugLogEntryWithMutex("DtxRayDetector::startDeviceAcquistions for " + debugID);
          QFuture<void> qf;
          qf = QtConcurrent::run(_dt.xAcq->Snap());
      
      }
      

      I get an error: No matching function for call to run.

      I'm guessing this is a syntax issue that I just don't understand. I've tried a couple of variations that haven't worked. Do you see what I need to do differently?

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

      @dwilliams said in Running a member function in a QtConcurrent thread:

      Is _dt.xAcq as QObject sub-class instance and Snap() a slot?
      In this case, supposing xAcq class name ist XAcq you can do:

      qf = QtConcurrent::run(_dt.xAcq, &XAcq::Snap);
      

      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
      • D Offline
        D Offline
        dwilliams
        wrote on last edited by
        #3

        That worked. Thank you!

        KroMignonK 1 Reply Last reply
        1
        • D dwilliams

          That worked. Thank you!

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

          @dwilliams your welcome

          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

          • Login

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