的Windows 7 SP1
MSVS 2010
Qt庫4.8.4的Windows(VS 2010)
Visual Studio的外接1.1.11對的Qt4爲什麼Qt不會在信號/插槽中產生無效的類名/類型名稱的編譯錯誤?
我,起初,無法弄清楚爲什麼這個插槽沒有觸發:
connect (lineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(enableFindButton(const Qstring &)));
差異很明顯:Qstring應該是QString。
我的問題:爲什麼編譯?實際上,它會用這個編譯:
connect (lineEdit, SIGNAL(textChanged(const nonsense &)),
this, SLOT(enableFindButton(const more_nonsense &)));
這是預期的行爲嗎?爲什麼這不會產生錯誤?
http://stackoverflow.com/questions/5880763/qt-signal-slot-macro-declaration?lq=1(其中包括) –
這僅僅是因爲MOC(元對象編譯器)不夠智能,無法推斷類型,但Qt應該在運行時產生一些警告信息,表示信號不能和插槽連接。 – doc