QT編譯時出現警告 Warning: Class Node implements the interface QGraphicsItem but does not list it in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!


1.一定要將public QObject放在public QGraphicsItem的前面,並且在該類的定義中添加Q_OBJECT宏.

class XXGraphicsItem : public QObject, public QGraphicsItem 

編譯時出現警告 Warning: Class Node implements the interface QGraphicsItem but does not list it in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!

在類的聲明(Q_OBJECT下面)中添加:Q_INTERFACES(QGraphicsItem)可解決該問題.

class XXGraphicsItem : public QObject, public QGraphicsItem 
{
	Q_OBJECT
	Q_INTERFACES(QGraphicsItem)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM