singal slot 三種調用機制

 

signal/slot目前有三種調用方式

1.DirectConnection

和以前一樣,在emit處直接invoke你的slot函數,一般情況是sender,receiver在同一線程

e.g. emit currentRowChanged(...);

 

2.QueuedConnection

將發送Event給你的receiver所在的線程

postEvent(QEvent::MetaCall,...)

slot函數會在receiver所在的線程的event loop中進行處理,一般情況是sender,receiver不在同一線程

 

3.BlockingQueuedConnection

調用sendEvent(QEvent::MetaCall,...),在receiver所在的線程處理完成後纔會返回;只能當sender,receiver不在同一線程時纔可以

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章