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. What is the difference between QThread::terminated() and QThread::finished()?
Qt 6.11 is out! See what's new in the release blog

What is the difference between QThread::terminated() and QThread::finished()?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.2k 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.
  • P Offline
    P Offline
    prerna1
    wrote on last edited by
    #1

    I am writing an application that gets frames from a camera. I need to release the camera resources. Should I do this in QThread::terminated() or QThread::finished()?

    I would like to do it when the thread has completely finished executing all the code it had to execute.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Check the documentation: "QThread::terminate()":http://qt-project.org/doc/qt-5.0/qtcore/qthread.html#terminate is a slot that terminates the execution of the thread and "QThread::finished()":http://qt-project.org/doc/qt-5.0/qtcore/qthread.html#finished is a signal that is emitted by the thread before it finishes executing.

      http://anavi.org/

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prerna1
        wrote on last edited by
        #3

        I am NOT referring to the slot QThread::terminate(). I am referring to the signal QThread::terminated().

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          terminated is emitted when the thread has been, well, terminated (forcibly stopped) which also means that it's state is not guaranteed to be clean.

          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
          • L Offline
            L Offline
            leon.anavi
            wrote on last edited by
            #5

            [quote author="prerna" date="1370365766"]I am NOT referring to the slot QThread::terminate(). I am referring to the signal QThread::terminated().[/quote]

            Please note that since Qt 5 the signal QThread::terminated() has been removed, because its emission cannot be guaranteed.

            http://anavi.org/

            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