自定义QGraphicsItem的继承顺序

来源:互联网 发布:淘客发单软件 编辑:程序博客网 时间:2024/06/05 19:08
class Node : public QObject,public QGraphicsItem {Q_OBJECT      ....}

注意:一定要将public QObject放在public QGraphicsItem的前面,并且在该类的定义中添加Q_OBJECT宏.


编译时出现警告 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)可解决该问题.

0 0
原创粉丝点击