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