-1

I have a header file where i have:

enum event {UP, DOWN, LEFT, RIGHT, ACTION };

and I have Q_OBJECT class where I want to pass event type "events" as a signal paramater.

class GameView : public QGraphicsView {
            Q_OBJECT
            public:
                GameView(QWidget* parent, GameModel *m);
            ...
            signals:
                void sendEvent(event e);
            ...
};

But when I try to build it, the compiler says

'event' is not a type.

How can i pass the enumerator as a type correctly for the signal?

Hackensack
  • 27
  • 3
  • Is it the compiler? Is it moc? What's the *complete* error message? – peppe Mar 25 '17 at 17:24
  • Possible duplicate of [How to use enums in Qt signals and slots](http://stackoverflow.com/questions/12368712/how-to-use-enums-in-qt-signals-and-slots). You're also missing the `Q_DECLARE_METATYPE` macro (in the question). **Do your research next time.** – LogicStuff Mar 25 '17 at 17:26

1 Answers1

0

It is not a matter of signals or Qt. It is pure C++.

event is a member function of QGraphicsView. So when you write void sendEvent(event e);, event is not a type but a function.

You could write void sendEvent(::event e); which will force to resolve event at global scope.

Benjamin T
  • 8,120
  • 20
  • 37