Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt4 创建QGraphics站点列表时出错_Qt4_Qlist_Qgraphicsscene - Fatal编程技术网

Qt4 创建QGraphics站点列表时出错

Qt4 创建QGraphics站点列表时出错,qt4,qlist,qgraphicsscene,Qt4,Qlist,Qgraphicsscene,我有一个Qgraphicscene,我想在上面画一些特殊的曲线。为此,我创建了一个类,其中我将这些特殊曲线定义为新的QGraphicsItem: #include < QGraphicsItem> class Clothoid : public QGraphicsItem { public: Clothoid(QPoint startPoint, QPoint endPoint); virtual ~Clothoid();

我有一个Qgraphicscene,我想在上面画一些特殊的曲线。为此,我创建了一个类,其中我将这些特殊曲线定义为新的QGraphicsItem:

#include < QGraphicsItem> class Clothoid : public QGraphicsItem { public: Clothoid(QPoint startPoint, QPoint endPoint); virtual ~Clothoid(); QPoint sPoint; QPoint ePoint; float startCurvature; float endCurvature; float clothoidLength; protected: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); }; #包括<-QGraphicsItem> 类回旋线:公共QGraphicsItem { 公众: 回旋线(QPoint起点、QPoint终点); 虚~回旋线(); 点sPoint; 点ePoint; 浮式起动器; 浮动端曲率; 浮动长度; 受保护的: QRectF boundingRect()常量; 无效绘制(QPainter*painter、const QStyleOptionGraphicsItem*选项、QWidget*小部件); }; 我尝试将每个项插入两次:在我定义的数组中插入一次:

QList< Clothoid> clothoids; QList<回旋线>回旋线; 一旦进入现场:

void renderArea::updateClothoid(const QPoint &p1, const QPoint &p2) { Clothoid *temp = new Clothoid(p1, p2); clothoids.append(&temp); scene->addItem(&temp); } 无效渲染区域::更新轮廓(常量QPoint和p1,常量QPoint和p2) { 回旋线*温度=新回旋线(p1,p2); Clothids.附加(&temp); 场景->添加项(&temp); } 但我有两个错误:

对“QList::append(Clotooid**)”的调用没有匹配的函数

调用“QGraphicscene::addItem(Clotooid**)”时没有匹配的函数

我做错了什么

应该是:

clothoids.append(temp);
scene->addItem(temp);
QList应定义为:

QList<Clothoid*> clothoids;
QList回旋线;
应该是:

clothoids.append(temp);
scene->addItem(temp);
QList应定义为:

QList<Clothoid*> clothoids;
QList回旋线;

像这样尝试,现在QGraphicscene的错误消失了,但qlist的错误仍然存在。qlist应该包含指向Clothoid对象的指针。我已经用代码更新了我的答案。像这样尝试过,现在QGraphicscene的错误消失了,但qlist的错误仍然存在。qlist应该包含指向Clothoid对象的指针。我已经用代码更新了我的答案。