G ++ Analysis error in ":"

g++ reports a parsing error using 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 declared the Q_OBJECT macro before the error, but if I comment on the slots part, it compiles fine. I have used Qt for many years and have never seen this before, it must be something stupid, but I do not see what causes the problem.

+7
source share
1 answer

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

You must move the typedef to a public, secure, 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: ... 
+6
source

All Articles