2011-08-02 18 views
1

QGraphicsSceneを使用して、いくつかの特殊な曲線を描きたいと思います。そのために私は新しいQGraphicsItemとしてこれらの特別な曲線を定義するためのクラス作っ:QGraphicsItemsのリストを作成するとエラーが発生する

 

    #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); 
    } 

しかし、私はこれらの2つのエラーを取得:QListに「への呼び出しのため

なしマッチング機能を::私は間違って何をやっている 'QGraphicsScene ::のaddItem(クロソイド**)「への呼び出しのために

一致する関数'

を(クロソイド**)を追加していませんか?

でなければなりません

答えて

1

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

QListのように定義する必要があります。

QList<Clothoid*> clothoids; 
+0

はそのようにしようと、今qgraphicssceneのエラーは消えたが、QListのための1がまだそこにあります。 – schmimona

+0

QListにはClothoidオブジェクトへのポインタが含まれている必要があります。私はコードで自分の答えを更新しました。 –

+0

ありがとう – schmimona

関連する問題