Is there any way to know whether inst1
or inst2
was the trigger for the slot in the next code?
MyClass inst1 ,inst2;
connect (inst1, sigInst1(), this, mySlot());
connect (inst2, sigInst2(), this, mySlot());
void mySlot(){
// here I want to know if inst1 or inst2 got me into this slot.
}
Just call sender()
and you get the pointer of the object emitting the signal.
Entry for QObject * QObject::sender() const [protected]
in documentation is here.