I’m using separate class files for each section of the UI I’m writing, i.e. for a bunch of widgets in a stackable widget or tabbed widget, I’d have separate classes for each container widget.
The question is, which component is responsible for wiring a signal from one widget to a slot on another widget?
I considered putting that code in the constructor of a parent widget that contains both the child widgets, but that would require hard coding the path to the signal and slot which would make it a bit coupled/hard to maintain if we change the UI.
Alternatively, I could try to put signals and slots at each level of the hierarchy, and basically manually propagate the events between the widgets. For example: source widget → parent → parent → child → child → target widget
I considered using a custom Event and the signaling widget would call QCoreApplication.postEvent(self, MyCustomEvent()), which would propagate up to the QMainWindow eventually.
The problem then comes with how do I get the event to flow down to my handler? Do I install an eventFilter on the QApplication.instance() ?
And the final option was a separate EventManager that gets injected into the widgets and handles communication? (Least preferred)
Any thoughts or insights?