2013-04-21 28 views
1

有什麼方法可以知道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. 

} 

回答

4

只要撥打sender(),您就會得到發射信號的物體的指針。

QObject * QObject::sender() const [protected]在文檔中的輸入是here