Monitor a Signal of an object not always present(?).
My question is about monitoring a signal emitted from a particular type of object (class), and not from an object itself (instance).
I have a "manager" for my data structure, where I handle (centralized) every data inside my program, and I have a set of dialogs that interacts with the user. The dialog objects are created when the proper buttons are clicked. The "manager" is always present, of course, from the start till the end of the program run. On a particular dialog I want to emit a signal, so that the manager can capture it and execute the appropriate slot.
So, how do I connect a signal from a object that will exist (the dialog) -- but is not always present/instantiated -- to a slot on my program's slot?
Obs: I've used the Signal/Slot connections already in my program, but always between objects that are always present/instantiated, but I am not seeing how to do the current situation.
Thanks a lot in advance!
I am not very proficient but I think following could be done: As you stated that manager is always present, may be it could be implemented as Singleton and a set of classes can be made aware of that Singleton class. So that each object of "Set of classes" can connect itself to a particular slot of "Singleton" manager or call a method on singleton object that will do the connecting. That ways you wont have to worry about connecting them elsewhere.
I hope it helps!
Simply create the connection at the moment you instantiate the object.