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
Forum Updated to NodeBB v4.3 + New Features

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.
  • michalt38M Offline
    michalt38M Offline
    michalt38
    wrote on last edited by
    #1

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

    J.HilkJ 1 Reply Last reply
    0
    • 6thC6 Offline
      6thC6 Offline
      6thC
      wrote on 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
      • michalt38M michalt38

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

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on 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

        • Login

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