Answer the question
In order to leave comments, you need to log in
What is the best way to bind signals and slots in a complex class hierarchy if it needs to be done manually by code (without Qt Designer)?
Suppose the controls are on forms (QWidget), which are themselves children of their windows, and there are many of these windows. And so you need to connect signals and slots between these controls in different windows, on different forms (without the designer's cutie). Then it is better to do it in the main window class and pass links to these forms to it? But some kind of hardcode is obtained and cumbersome. What is the right and best way to do it? They don't talk about it in tutorials :/
Answer the question
In order to leave comments, you need to log in
In general, there is usually some kind of initialization point where all child forms are created. If they must somehow interact with the main form, then at this initialization point they must be connected. Maybe it's the main form's constructor, or a method like init(). The same method can be used for child widgets. if they need to be connected to the slot signals of the descendants.
If objects are created by some factory, then there they must be connected with dependencies using slot signals.
It is better for the designer not to connect anything at all. It turns out pretty ugly in the end.
Anyway, post an example. Here or on gihab. It's hard to tell without code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question