PDA

View Full Version : Relaying signals--Is this typical, or is it a bad design?



davethomaspilot
24th December 2014, 11:19
I frequently have Q_Object classes that contain other Q_Objects as private members. Signals that occur in these contained QObjects need to be connected by the owner of the class that contains them. Consequently I end up creating slots in classes that own Q_Objects that do nothing other than emit a duplicate signal of what caused them to be executed.

For example, say class (QObject A) contains a QObject B and a QObject C. Furthermore, QObject B contains a QObject D.

A signal that occurs in QObject D needs to be connected to a slot in QObject C. To do this, I create a slot in QObject B. It's connected in B's code to a slot in B that emits a signal This B signal is then be connected to QObject D in a method in QObject A.

I could instead declare the the contained Objects (and/or methods) B and D public so the owning classes can do the connection directly, but I'm wondering if this is a typical situation? Does this indicate a bad design? or am I "picking at nits"?

yeye_olive
24th December 2014, 11:27
You can connect a signal to another signal.

davethomaspilot
24th December 2014, 12:49
Never saw that and that's what I needed!

Thanks