QT中添加自訂Class,出現“undefined reference to vtable for”之解決方案(Eclipse+Linux)

來源:互聯網
上載者:User

用Eclipse開發QT都GUI應用,想自訂一個Class,考慮要用到訊號/槽機制,所以在自訂的Class中加入來    Q_OBJECT 宏。但是Build時,報錯!形如:

undefined reference to vtable for

在網上查了良久,發現了原因《

Qt 出現“undefined reference to `vtable for”原因總結
》,但是解決方案可操作性太差。



undefined reference to 'vtable for‘解決辦法

》中的解決方案道是有參考性,只是不是Eclipse的IDE開發環境下的。

於是繼續查啊找啊。。。。。

在《'Undefined reference to vtable' when inheriting from QObjec
t》查到解決方案:

If you are using qmake sometimes you have to delete all your Makefiles
and regenerate them to get your new header file moc'ed

於是,在Eclipse的Project中單擊右鍵->Clean Project,發現所有都MakeFile檔案都重建了。再次Build,沒問題了


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.