日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

QMetaObject::connectSlotsByName: No matching signal for问题的解决方法

發(fā)布時(shí)間:2025/5/22 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QMetaObject::connectSlotsByName: No matching signal for问题的解决方法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天發(fā)現(xiàn)qt程序在運(yùn)行時(shí)命令行窗口會(huì)彈出下面的警告:

QMetaObject::connectSlotsByName: No matching signal for ...

但實(shí)際功能并沒有受影響。網(wǎng)上google了一圈,終于找到原因。

?

以下轉(zhuǎn)自:http://www.qtforum.org/article/20685/connectslotsbyname.html

After a bit of sleuthing to find the source of all the Qt warnings, “QMetaObject::connectSlotsByName: No matching signal for…”, in our log window/file, here’s what I’ve found.

setupUi calls connectSlotsByName. connectSlotsByName parses the moc_ file in order to connect slots and signals. The moc_ file contains a list of all the slots for the class. The parser iterates over the list of slot names looking for the following pattern: on_objectName_signal, where on_objectName_signal is the name of the slot, objectName is the object name and signal is the signal. For example, if you have a slot named, on_doneButton_clicked(), the parser looks for an object named doneButton, a signal named clicked and then connects the on_doneButton_clicked() slot to QButton’s signal clicked().

If you follow this naming convention, you do not need to call the connect() method, nor do you need to connect the signal via the Qt UI editor in VisualStudio. connectSlotsByName will automatically make the connection for you.

So, in order to get rid of the “No matching signal for…” warnings, we need to either follow this naming convention, or make sure none of our slot names begin with “on_”. If you have a slot, onDoneButton_clicked, for example, connectSlotsByName will no try to connect it with a signal, nor will emit an warning.

?

上面大概就是說:用VistalStudio里的QtEditer可以自動(dòng)調(diào)用Qt中“connectSlotsByName”即“按空間名稱關(guān)聯(lián)槽”的方式進(jìn)行關(guān)聯(lián),對(duì)應(yīng)的函數(shù)必須寫成“on_控件名_信號(hào)名”的格式;或者也可以通過connet函數(shù)人為顯式地將信號(hào)和槽關(guān)聯(lián)起來。但是,如果采用顯式connect的方法的同時(shí),又將槽函數(shù)的名字起成了“on_控件名_信號(hào)名”的格式,那么就會(huì)在運(yùn)行時(shí)彈出“QMetaObject::connectSlotsByName: No matching signal for”的警告了!

總結(jié)

以上是生活随笔為你收集整理的QMetaObject::connectSlotsByName: No matching signal for问题的解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。