I am working with the MVC architecture. I have my GUI all set up, and I have my controller using the model for data access. My question is: how do I set up bidirectional data flow between the controller and the GUI(view). I am using Qt, so When I hit a button, it will fire off an action. In order to make that Action fire off to the controller, I need an instance of it. Then from the controller side, I need an instance of the view so I can tell it how to behave. So, how can achieve this communication? Am I even on the right track? please let me know what you guys think.
Thanks
The view doesn’t need to be explicitly aware of the controller. The controller can connect to any of the view’s signals and the signals can relay relevant data or they can be empty. When the controller handles them in a slot, it can call methods on the view to fetch data if it isn’t already included in the signal. The controller can also call any view method at any time.
I usually connect widget(button) signals directly to slots in the view class and expose custom aggregate signals that a controller can connect to instead of exposing all the widgets themselves.