MouseEvents in GraphicsScene überladen.

Alles rund um die Programmierung mit Qt
Antworten
slash-ex
Beiträge: 239
Registriert: 30. März 2005 21:40

MouseEvents in GraphicsScene überladen.

Beitrag von slash-ex »

Ich habe eine QGraphicsScene und wollte die virtuellen MouseEvents überladen, aber kurioserweise funktioniert das nicht wegen der unteren Fehlermeldung.
die frage ist, warum ich vordeklarieren muss? Warum ist in der Def keine ‘GraphicsSceneMouseEvent’ drinne?

Code: Alles auswählen

class GraphicsScene : public QGraphicsScene
{
private:
...
public:
	GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent)
	{}
	GraphicsScene ( const QRectF & sceneRect, QObject * parent = 0 ) : QGraphicsScene(parent) {
		this->setSceneRect(sceneRect);
	}
	GraphicsScene ( qreal x, qreal y, qreal width, qreal height, QObject * parent = 0 ) : QGraphicsScene(parent) {
		this->setSceneRect(x, y, width, height);
	}
	~GraphicsScene() {
...
	}
...

protected:
...
	//Maus
	void mouseMoveEvent(GraphicsSceneMouseEvent *event);

	void mousePressEvent(GraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(GraphicsSceneMouseEvent *event);
	void mouseDoubleClickEvent(GraphicsSceneMouseEvent *event);
...
};

Code: Alles auswählen

./battlefield/scene.h:45: error: ‘GraphicsSceneMouseEvent’ has not been declared
./battlefield/scene.h:47: error: ‘GraphicsSceneMouseEvent’ has not been declared
./battlefield/scene.h:48: error: ‘GraphicsSceneMouseEvent’ has not been declared
./battlefield/scene.h:49: error: ‘GraphicsSceneMouseEvent’ has not been declared
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Re: MouseEvents in GraphicsScene überladen.

Beitrag von franzf »

slash-ex hat geschrieben: die frage ist, warum ich vordeklarieren muss? Warum ist in der Def keine ‘GraphicsSceneMouseEvent’ drinne?
Weil das QGraphicsSceneMouseEvent heißt...
Antworten