Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ Parse error at ":"

g++ is reporting a parse error with the code below:

class Sy_timeLineDelegateScene : public QGraphicsScene
{
    Q_OBJECT
public:
    Sy_timeLineDelegateScene( Sy_animPropertyTimeLine* timeline,
                              Sy_animClock* clock,
                              QObject* parent = nullptr );
    virtual ~Sy_timeLineDelegateScene() {}

protected slots:   // Parse error at ":"
    typedef QMap< Sy::Frame, Sy_timeLineDelegateKey* > DelegateTimeLine;
...

My class is derived from QObject and I have declared the Q_OBJECT macro before the error, but if I comment out the slots part, it compiles fine. I have used Qt for years and never seen this before, it must be something stupid, but I can't see what's causing the problem.

like image 839
cmannett85 Avatar asked May 31 '12 21:05

cmannett85


Video Answer


1 Answers

The "slots" and "signals" sections in a class definition should only contain functions; neither types nor member variables.

You should move the typedef in a public, protected or private section:

class Sy_timeLineDelegateScene : public QGraphicsScene
{
    Q_OBJECT
public:
    Sy_timeLineDelegateScene( Sy_animPropertyTimeLine* timeline,
                              Sy_animClock* clock,
                              QObject* parent = nullptr );
    virtual ~Sy_timeLineDelegateScene() {}

    typedef QMap< Sy::Frame, Sy_timeLineDelegateKey* > DelegateTimeLine;

protected slots:
...
like image 170
leemes Avatar answered Oct 29 '22 19:10

leemes