Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collecting threads in Qt

I am looking for a way to get all threads created by one of my class to let me use them (threads are created dynamically depending on the user and I can't predict how many will be working while my application is working). Is there a good way to get all thread objects pointers and put them in one place so I can manipulate those threads?

like image 398
Dzakub Avatar asked Mar 18 '12 10:03

Dzakub


1 Answers

As a first, the best solution would definitely to keep track of the QThread's created. Even if they are created "on-the-fly", you should be able to store pointer to them, even globally.

Assuming they are at least parented to the same QObject, you could use:

QList<QThread*> QObject::findChildren <QThread*> () const

To find all child QThread's

like image 115
Chris Browet Avatar answered Sep 30 '22 08:09

Chris Browet