创建 QGraphicsItems 列表时出错
我有一个 QGraphicsScene,我想在其上绘制一些特殊的曲线。为此,我创建了一个类,在其中将这些特殊曲线定义为新的 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); };
并且我尝试将每个项目插入两次:一次在我定义的数组中:
QList< Clothoid> clothoids;
一次在场景中:
void renderArea::updateClothoid(const QPoint &p1, const QPoint &p2) { Clothoid *temp = new Clothoid(p1, p2); clothoids.append(&temp); scene->addItem(&temp); }
但我收到这两个错误:
没有匹配的函数用于调用“QList::append(Clothoid**)”,
并且
没有匹配的函数用于调用“QGraphicsScene::addItem(Clothoid**)”
我做错了什么?
I have a QGraphicsScene on which I would like to draw some special curves. For that I made a class in which I define these special curves as a new 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); };
and I try to insert each item twice: once in an array I defined:
QList< Clothoid> clothoids;
and once in the scene:
void renderArea::updateClothoid(const QPoint &p1, const QPoint &p2) { Clothoid *temp = new Clothoid(p1, p2); clothoids.append(&temp); scene->addItem(&temp); }
But I get these 2 errors:
no matching function for call to 'QList::append(Clothoid**)'
and
no matching function for call to 'QGraphicsScene::addItem(Clothoid**)'
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那应该是:
QList 应该定义为:
That should be:
The QList should be defined as: