有没有办法知道inst1
或inst2
是否是下一个代码中插槽的触发器?
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.
}
答案 0 :(得分:4)
只需调用sender()
即可获得发出信号的对象指针。
文档中QObject * QObject::sender() const [protected]
的条目为here。