久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Q_OBJECT 拋出“對(duì) vtable 的未定義引用"錯(cuò)誤

Q_OBJECT throwing #39;undefined reference to vtable#39; error(Q_OBJECT 拋出“對(duì) vtable 的未定義引用錯(cuò)誤)
本文介紹了Q_OBJECT 拋出“對(duì) vtable 的未定義引用"錯(cuò)誤的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我在 Windows 7 Ultimate 32 位上使用 Qt Creator 2.0.1 和 Qt 4.7.0(32 位).

I'm using Qt Creator 2.0.1 with Qt 4.7.0 (32 bit) on Windows 7 Ultimate 32 bit.

考慮以下代碼,這是產(chǎn)生錯(cuò)誤的最低限度:

Consider the following code, which is a minimum to produce the error:

class T : public QObject, public QGraphicsItem
{
    Q_OBJECT

public:
    T() {}

    QRectF      boundingRect() const {return QRectF();}
    void        paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                      QWidget *widget) {}
};

int main()
{
    T t;
    return 0;
}

以上代碼片段導(dǎo)致以下鏈接器錯(cuò)誤:

The above code fragment causes the following linker errors:

在函數(shù)‘T’中:

未定義的對(duì)`vtable for T'的引用

undefined reference to `vtable for T'

未定義的對(duì)`vtable for T'的引用

undefined reference to `vtable for T'

在函數(shù)`~T'中:

未定義的對(duì)`vtable for T'的引用

undefined reference to `vtable for T'

未定義的對(duì)`vtable for T'的引用

undefined reference to `vtable for T'

如果我注釋掉包含 Q_OBJECT 的行,它編譯正常.我需要帶有 QGraphicsItem 的信號(hào)和插槽,所以我需要 Q_OBJECT.

If I comment out the line that contains Q_OBJECT, it compiles fine. I need signal and slots with QGraphicsItem so I need Q_OBJECT.

代碼有什么問(wèn)題?謝謝.

What is wrong with the code? Thanks.

推薦答案

這是因?yàn)?MOC 生成的單元未包含在鏈接過(guò)程中.或者它根本沒(méi)有生成.我要做的第一件事是將類聲明放在一個(gè)單獨(dú)的頭文件中,也許構(gòu)建系統(tǒng)沒(méi)有掃描實(shí)現(xiàn)文件.

It is because the unit generated by MOC isn't included in the linking process. Or maybe it isn't generated at all. The first thing I'd do is to put the class declaration in a separate header file, perhaps the build system isn't scanning implementation files.

還有一種可能是這個(gè)類曾經(jīng)不屬于Qt元對(duì)象系統(tǒng)(也就是說(shuō),它沒(méi)有Q_OBJECT或者可能根本沒(méi)有繼承自QObject),所以需要再次運(yùn)行qmake才能順序?yàn)?MOC 創(chuàng)建必要的規(guī)則.強(qiáng)制運(yùn)行 qmake 的最簡(jiǎn)單方法是對(duì)項(xiàng)目文件進(jìn)行一些微不足道的更改以更新其時(shí)間戳,例如添加然后刪除一些空格.或者,如果您使用的是 Qt Creator,則只需從項(xiàng)目上下文菜單中選擇運(yùn)行 qmake"即可.

Another possibility is that the class in question once didn't belong to Qt meta object system (that is, it had no Q_OBJECT or maybe didn't inherit from QObject at all), so qmake needs to be run again in order to create the necessary rules for MOC. The easiest way to force qmake to be run is to make some insignificant changes to the project file to update its timestamp, like adding and then removing some white space. Or, if you're using Qt Creator, then just select "Run qmake" from the project context menu.

這篇關(guān)于Q_OBJECT 拋出“對(duì) vtable 的未定義引用"錯(cuò)誤的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫(xiě) for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 奇米影视首页 | 日本在线一区二区三区 | 国产精品99久久久久久动医院 | 亚洲精品一区av在线播放 | 欧美亚洲第一区 | 欧洲一区二区三区 | www.亚洲精品 | 亚洲成人国产 | 亚洲一区二区三区福利 | 国产精品欧美一区喷水 | 国产精品久久久久久久久久久久 | 国产目拍亚洲精品99久久精品 | 国产伦精品一区二区三区高清 | 亚洲国产精品久久久久婷婷老年 | 一级毛片视频在线 | 中文字幕国产 | av香港经典三级级 在线 | 亚洲一区二区在线播放 | 日日夜精品视频 | 精品视频一区二区三区在线观看 | 18gay男同69亚洲网站 | 男人天堂国产 | 国产精品99久久久久久宅男 | 干干干日日日 | 日韩精品免费在线观看 | 日韩免费视频一区二区 | 亚洲精品久久久久久久久久久久久 | 国产资源在线视频 | 一区二区三区免费 | 一级视频黄色 | 国产在线一区二区三区 | www.日本国产 | av天天爽 | 亚洲天堂中文字幕 | av一区二区三区四区 | 国产 日韩 欧美 中文 在线播放 | 国产一区不卡 | 四色永久| 毛片免费在线 | 欧美一级大片免费观看 | 在线第一页 |