I need to access the signaling object from the slot function in Qt. The reason being that I'm trying to keep the view and controller separate (implementing the MVC pattern), and the slot function, being in the controller class, has to update the view class to update a label.
I realize there are several ways to do this (a likely-wrong one that comes to mind is to make the view class a singleton and request the singleton object from the slot method in the controller class). What's the "right" way to accomplish this?
There is QObject::sender()
sender method, but i personally do not like working with it (be careful, pointer is only valid while executing the slot and only if called from same thread). If you have a managable amount of senders or not only need to have only the sender object, you can also use QSignalMapper
, which is my prefered identification on dynamically created lists of widgets.