QT connect的使用心得
本文記錄在項目中使用connect遇到的問題。
- 連接了信號,但是槽函數沒有響應,問題出在connect函數上
connect的簽名如下:
connect(ui->bntShow,//sender 發送者
SIGNAL(clicked(bool)),// signal 信號(事件)
this,// receiver 接受者
SLOT(OnTest(bool))//slot槽(事件處理函數)
);
1.檢查返回值
bool ret = connect(...)
if(!ret)...
檢查返回值,如果connect失敗返回false