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. Killing all threads when closing program

Killing all threads when closing program

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.6k 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.
  • M Offline
    M Offline
    michalt38
    wrote on 16 Jan 2018, 22:22 last edited by
    #1

    Is there a way to kill all of the living threads when closing a program?

    J 1 Reply Last reply 17 Jan 2018, 06:01
    0
    • 6 Offline
      6 Offline
      6thC
      wrote on 17 Jan 2018, 04:03 last edited by
      #2

      A signal that the application is shutting down, DTOR's, ThreadPools, WorkerThreads...

      Without knowing your setup and even if I did know... I'm just going to say err yes?

      Was there a specific case you were thinking / up against?

      1 Reply Last reply
      0
      • M michalt38
        16 Jan 2018, 22:22

        Is there a way to kill all of the living threads when closing a program?

        J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 17 Jan 2018, 06:01 last edited by
        #3

        @michalt38
        hi, closing a program implicates the termination of all threads. Am I right in assuming, you want to stop all threads when the UI is closed?

        You can do a Signal/Slot connect when you create the thread to a complish that:

        QObject::connect(qApp, &QCoreApplication::aboutToQuit, myThread, &QThread::quit);
        

        or if your QThread is a class member you can handle that in the destructor:

        myClass::~myClass(){
            myThread->quit();
            myThread->wait();
        }
        

        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.

        1 Reply Last reply
        5

        1/3

        16 Jan 2018, 22:22

        • Login

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