Silly question: QGraphicsEllipseItem



  • I'm just playing around with QGraphicsEllipseItem. I'm trying to do something like this:
    Ball.h
    @
    #ifndef BALL_H
    #define BALL_H

    #include <QtGui>

    class Ball : public QGraphicsEllipseItem
    {
    Q_OBJECT
    public:
    explicit Ball(void);
    };

    #endif // BALL_H
    @
    ball.cc
    @#include <QtGui>
    #include "Ball.h"

    Ball::Ball(void)
    : QGraphicsEllipseItem(85, 0, 30, 30)
    {
    setBrush(QBrush(Qt::red));
    setPen(QPen(Qt::red));
    }
    @

    For some reason I'm getting a "undefined reference to `vtable for Ball'" during the linking stage (gcc 4.4.5). Any ideas what I'm forgetting here? Thanks!



  • I should add on to this I guess. The documentation specifies some virtual functions under "Reimplemented Public Functions". Do I have to re-re-implement them? Or is there something else I'm missing.



  • QGraphicsItems are not QObjects, so remove that Q_OBJECT macro and rerun qmake if necessary.



  • Thanks! It worked.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.