1

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.

}
4

1 回答 1

5

只需调用sender()即可获得发出信号的对象的指针。

QObject * QObject::sender() const [protected]文档中的条目在这里

于 2013-04-21T09:00:42.370 回答