void QMetaObject::connectSlotsByName (QObject *object ) [static]
Searches recursively for all child objects of the given object, and connects matching signals from them to slots ofobject that follow the following form:
系統會對所有給定的子對象進行遞歸檢索,並連接依據以下命名規則的對象的槽函數和信號函數:
void on_<object name>_<signal name>(<signal parameters>);
void on_<對象名>_<信號名>(<信號參數>);
Let's assume our object has a child object of type QPushButton with the object name button1. The slot to catch the button's clicked() signal would be:
我們來舉個例子,如果我們的對象有一個QPushButton的子對象,它的名字叫button1。那麼要系統自動連接這個按鈕的點擊(clicked())信號,應該在你的程序中如下命名:
void on_button1_clicked();
See also QObject::setObjectName(). 相關瀏覽
以下介紹另一個方法:從界面自動在代碼中生成響應函數
on_pushButton_clicked() 自動連接命名規則。用Qt-creator右鍵點擊Button後選擇go to slot項後自動生成的槽的名字就是這個。
自己命名槽的時候還是迴避此規則的好。
我用VS加QT,所以沒見到這個選項