How to catch MouseEvent from QGraphicsScene, LinkError
-
Hi
im trying to catch mouseevents from QGraphicsScene by using this ugly SIGNAL-SLOT mechanism.
Im getting compile error: "error LNK2019" mouseClick not found...
I hope some one can tell me what im doing wrong.
thx
cgraphicsscenePlugins.h
@
#ifndef CGRAPHICSSCENEPLUGINS_H
#define CGRAPHICSSCENEPLUGINS_H#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QObject>class CGraphicsScenePlugins : public QGraphicsScene{
public:
CGraphicsScenePlugins(QObject *parent = 0);protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event );signals:
void mouseClick(QGraphicsSceneMouseEvent* event);
};#endif // CGRAPHICSSCENE_H
@cgraphicsscenePlugins.cpp
@
#include "cgraphicsscenePlugins.h"CGraphicsScenePlugins::CGraphicsScenePlugins(QObject *parent) : QGraphicsScene() {
}void CGraphicsScenePlugins::mousePressEvent(QGraphicsSceneMouseEvent * event ) {
QGraphicsScene::mousePressEvent(event);
emit mouseClick(event);
}@
-
-
I think that signals and slots are not required in your case. You can call a simple method instead of emitting a signal or you can write the code that you want the application to execute when it receives a mouse press event, inside the mousePressEvent() method. it will be executed automatically !!