1

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 &lt 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&lt 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?

schmimona
  • 849
  • 3
  • 20
  • 40

1 Answers1

2

That should be:

clothoids.append(temp);
scene->addItem(temp);

The QList should be defined as:

QList<Clothoid*> clothoids;
laurent
  • 88,262
  • 77
  • 290
  • 428
  • tried like that and now the error for the qgraphicsscene disappeared but the one for the qlist is still there. – schmimona Aug 02 '11 at 08:53
  • The QList should contains pointers to Clothoid objects. I have updated my answer with the code. – laurent Aug 02 '11 at 08:55