2

I'm trying to make a game, and i've created a class for the Player. The class inherits "Entity", which inherits QGraphicsItem.

#ifndef PLAYER_H
#define PLAYER_H

#include "entity.h"

class Player : public Entity
{
public:
    Player( QString, int, int, int position );

    QRectF boundingRect() const;
    void paint( QPainter *painter,
                const QStyleOptionGraphicsItem *option,
                QWidget *widget );

    void move_north();
    void move_south();
    void move_west();
    void move_east();

    void start_moving();
    void stop_moving();

    void switch_step();

    bool its_moving();

    void change_pos(int);

private:
    QPoint position;
    bool is_moving;

private signals:
    void Move();
};

#endif // PLAYER_H

But i keep getting the error "expected ':' before 'protected'", at line 33.

p.i.g.
  • 2,815
  • 2
  • 24
  • 41
Kanghu
  • 561
  • 1
  • 10
  • 23

2 Answers2

8
// private signals:
signals:

There should be no access modifiers on signals, you only do that for slots.

Internal to the MOC, Qt replaces signals with its own access modifiers, which is where the protected comes from.

Tom Kerr
  • 10,444
  • 2
  • 30
  • 46
6

This answer has some relevant insights. Signals are by definition protected, so you're code is getting converted to private protected:, which the compiler complains about.

In other words, you can't say private signals:. Just say signals:.

Community
  • 1
  • 1
Cornstalks
  • 37,137
  • 18
  • 79
  • 144