PDA

View Full Version : emit with destination



nuliknol
19th March 2015, 10:23
Hi,
I need to emit a signal to a certain destination object, is this possible ? Checkted the emit() keyword and it doesn't accept any parameter except signal name.

TIA

yeye_olive
19th March 2015, 10:42
Please define what you mean by "emit a signal to a certain destination object".

Here is a possible interpretation of this phrase: "make a QObject o emit one of its signals s". This seems strange, because o is expected to decide for itself when it is appropriate to emit s. Nevertheless, one way of doing it is to call o.someMethod(), where someMethod() executes emit s(...). Or, especially if you have no control on o's class, have another QObject emit a signal which is connected to o.s; the connection will cause o to emit s.

Here is another possible interpretation: "execute a slot s of a QObject o". Slots are regular methods; you can simply call o.s().

wysota
19th March 2015, 10:52
If you know the destination object then you can just call its method directly. Signals are meant to be destination-agnostic.

nuliknol
19th March 2015, 13:17
sorry, that's exatly what I need: call the slot of an object directly
because I have access to the class, I am writing it actually.
thanks yeye.
regards