Hi,
I made a prototype of a project with PyQt and made it work there, now I'm trying to convert it to C++ and am having some problems.
If I don't put the Q_OBJECT macro in, it compiles and works, but if I comment it out, I get the following errors:
Undefined symbols:
"vtable for MapView", referenced from:
MapView::~MapView()in mapview.o
MapView::~MapView()in mapview.o
MapView::MapView(QObject*)in mapview.o
MapView::MapView()in mapview.o
"MapView::staticMetaObject", referenced from:
MapView::MapView(QObject*)in mapview.o
MapView::MapView()in mapview.o
Here's the header:
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QtGui>
#include <QObject>
class MapView : public QGraphicsScene
{
//Q_OBJECT
public:
MapView();
explicit MapView(QObject *parent = 0);
QGraphicsPixmapItem *mappixmap;
~MapView();
private:
bool dragging;
float offsetX, offsetY, downoffsetX, downoffsetY;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
};
#endif // MAPVIEW_H
Secondary question is will Bad Things happen if I just omit the Q_OBJECT macro here?
And yes, I'm aware of that it's stupid to call a QGraphicsScene a "view".