PDA

View Full Version : Collect signals from multiple QObjects



HappyCoder
15th May 2017, 16:28
Hi,

the Object analogCheck emits a signal finished(), when the analog check has finished.
The object is created multiple times (up to 20x).
What is the best way to collect all fnished() signals from all created "analogCheck *dev = new analogCheck(pDev, this)".
For me i would connect all finished() signals to the same slot and increment a counter with each calling and when
the counter reaches the counter of created objects i collected all finished() signals.

Is there a better way?



QPointer<deviceAnalog> pDev = new deviceAnalog(channel, serial, devType, this);
analogCheck *dev = new analogCheck(pDev, this);

Lesiok
15th May 2017, 18:34
Use QList with analogCheck pointers. In slot from signal finished() remove signal sender from list. An empty list means that all objects have finished.

HappyCoder
16th May 2017, 07:11
Use QList with analogCheck pointers. In slot from signal finished() remove signal sender from list. An empty list means that all objects have finished.
Yes, that's a better idea than a counter. Thank You