Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to make separate thread for a callback function using QtConcurrent?
Forum Updated to NodeBB v4.3 + New Features

How to make separate thread for a callback function using QtConcurrent?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 329 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.
  • R Offline
    R Offline
    Renu
    wrote on last edited by
    #1

    How to make separate thread for a callback function using QtConcurrent?
    a statement for a bit clarity:
    camera->requestCompleted.connect(this, &TestCam::requestComplete);
    where requestComplete is a function

    jsulmJ 1 Reply Last reply
    0
    • R Renu

      How to make separate thread for a callback function using QtConcurrent?
      a statement for a bit clarity:
      camera->requestCompleted.connect(this, &TestCam::requestComplete);
      where requestComplete is a function

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

      @Renu Why do you need a thread?
      If you really need a thread then use a worker object which implements that slot and runs in another thread. The connect statement will make sure the slot is called in that other thread (don't use DirectConnection!).

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

      R 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Renu Why do you need a thread?
        If you really need a thread then use a worker object which implements that slot and runs in another thread. The connect statement will make sure the slot is called in that other thread (don't use DirectConnection!).

        R Offline
        R Offline
        Renu
        wrote on last edited by Renu
        #3

        @jsulm Is it not possible to use QtConcurrent to create a separate thread for the asked question?

        jsulmJ 1 Reply Last reply
        0
        • R Renu

          @jsulm Is it not possible to use QtConcurrent to create a separate thread for the asked question?

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

          @Renu Why do you need QtConcurrent?
          If you really want to use it you can call https://doc.qt.io/qt-6/qtconcurrent.html#run inside requestComplete to delegate the work to another thread.

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

          R 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Renu Why do you need QtConcurrent?
            If you really want to use it you can call https://doc.qt.io/qt-6/qtconcurrent.html#run inside requestComplete to delegate the work to another thread.

            R Offline
            R Offline
            Renu
            wrote on last edited by
            #5

            @jsulm I thought QtConcurrent would be less complex to use

            SGaistS 1 Reply Last reply
            0
            • R Renu

              @jsulm I thought QtConcurrent would be less complex to use

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Renu hi,

              QtConcurrent already running tasks in different threads, why do you need to create a new separate one ?

              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
              0

              • Login

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