Dzakub
Dzakub

Reputation: 73

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?

Upvotes: 5

Views: 2619

Answers (1)

Chris Browet
Chris Browet

Reputation: 4276

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

Upvotes: 5

Related Questions