Number of active QThreads
-
Is there any way to get pointers to all active QThreads at any point in the application? I realize that I can create a class inherited from QThread and implement this functionality there, but I am interested in the standard QThread.
I've tried looking at the events received in "eventFilter", but it didn't give any result -
@TurashviliAlik QThread does not have such functionality (and I don't know why you would need it).
If you're using thread pools you can use https://doc.qt.io/qt-6/qthreadpool.html#activeThreadCount-prop -
@TurashviliAlik
Since you are creating these QThread objects why not just keep aQList<QThread*>
. Alternatively, parent them all to a single QObject (likeqApp
) and then find them with QObject::findChildren()QList<QThread *> threads = qApp->findChildren<QThread*>();
Like @jsulm, I am not sure why you would need this.