检查哪个信号是信号的来电者

时间:2013-04-21 08:46:11

标签: qt signals-slots

有没有办法知道inst1inst2是否是下一个代码中插槽的触发器?

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.

}

1 个答案:

答案 0 :(得分:4)

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

文档中QObject * QObject::sender() const [protected]的条目为here