問題描述
我設置了一個QT菜單,它自動連接到動作函數on_actionOpen_triggered()
.后來我想將文件名字符串傳遞給這個函數,以便在特殊情況下手動調用這個函數.所以我將函數簽名更改為 on_actionOpen_triggered( const char *filename_in )
.修改后程序運行良好,但終端報錯,
I set a QT menu, which is automatically connected with action function on_actionOpen_triggered()
. Later I want to pass a filename string to this function in order to call this function manually in a special condition. So I changed the function signature to on_actionOpen_triggered( const char *filename_in )
. After this change the program is running well, but there is a complain in terminal,
QMetaObject::connectSlotsByName: on_actionOpen_triggered(const char*) 沒有匹配的信號
QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*)
我想知道發生了什么,以及如何為此菜單操作功能添加參數.
I am wondering what happened, and how I can add arguments for this menu action functions.
謝謝.
推薦答案
我遇到了同樣的警告/錯誤
QMetaObject::connectSlotsByName: No matching signal for
并得到了簡單的解決方案.例如:
And got simple solution. For Example:
問題:QMetaObject::connectSlotsByName: on_actionOpen_triggered(const char*) 沒有匹配的信號
警告您只需要更改 Slot
Problem :
QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*)
Warning
You just need to change the name of the Slot
解決方案
更改插槽名稱,如 on_actionOpenTriggered
,此警告消失.
提示
Qt 嘗試理解其默認插槽,如 on_
,因此如果您指定任何具有上述簽名的插槽,Qt 將拋出警告.
Hint
Qt try to understand its default slot like on_<name_of_object>_<action>
, So if you specify any slot with above signature, Qt will throw warning.
希望對大家有所幫助.
這篇關于QMetaObject::connectSlotsByName: 沒有匹配的信號的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!