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)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-09-11
  • 2021-10-20
  • 2021-11-24
  • 2022-01-20
  • 2022-02-19
猜你喜欢
  • 2021-11-17
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案