我尝试连接if (!('remove' in Element.prototype)) {
Element.prototype.remove = function() {
if (this.parentNode) {
this.parentNode.removeChild(this);
}
};
}
子类和QGraphicsObject
子类(QGraphicsView
构造函数中包含以下行)
QGraphicsObject
但是我收到以下错误:
connect(this, SIGNAL(paintImage(QPainter *, const QImage &)), this->scene()->views().front(), SLOT(paintImage(QPainter *, const QImage &)));
我从文档中看到D:\Project\Scene\PointField.cpp:18: error : C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const: cannot convert 'QGraphicsView *' to 'const QObject *'
The point types are unrelated; conversion needs reinterpret_cast, C style cast or function style cast.
继承自QGraphicsView
,并且两个子类声明中都有QObject
宏...有人有想法吗?
答案 0 :(得分:5)
QGraphicsView
是connect()
调用中使用的不完整类型。编译器不知道它继承自QObject
,这就是它报告的原因
无法转换'
QGraphicsView *
'到'const QObject *
'
解决方案是在#include <QGraphicsView>
调用之前的某个位置执行文件中connect()
。
答案 1 :(得分:0)
我通过将QGraphicsView子类标题包含在QGraphicsObject子类标题的顶部,然后清理/执行qmake / rebuild来解决我的问题。