Seite 1 von 1

linker-error bei Aufruf von custom Signal in mousePressEvent

Verfasst: 27. Mai 2010 18:52
von jaronimo
EDIT: tut mir leid, hab wollte eigentlich ins Forum QT Programmierung posten..

ich will von meiner QGraphicsScene Infos (zb Mausposition) an mein mainwindow weitersenden und hab dafür in meiner QGraphicsScene ein custom Signal implementiert, das von mousePressEvent() emittiert wird.
beim Kompilieren bekomm ich aber dann einen linker-error, an dem ich jetzt schon eine Zeit lang tüftle...

Code: Alles auswählen

Error	1	error LNK2019: unresolved external symbol "protected: void __thiscall GraphicsScene::mousePos(class QPointF const &)" (?mousePos@GraphicsScene@@IAEXABVQPointF@@@Z) referenced in function "protected: virtual void __thiscall GraphicsScene::mousePressEvent(class QGraphicsSceneMouseEvent *)" (?mousePressEvent@GraphicsScene@@MAEXPAVQGraphicsSceneMouseEvent@@@Z)	GraphicsScene.obj

Code: Alles auswählen

#ifndef GRAPHICSSCENE_H
#define GRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
using namespace std;
class GraphicsScene : public QGraphicsScene
{
public:
	GraphicsScene( QObject *parent = 0);

protected:
	void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );

signals:
	void mousePos( const QPointF& );
};
#endif // GRAPHICSSCENE_H

Code: Alles auswählen

#include "GraphicsScene.h"

GraphicsScene::GraphicsScene( QObject *parent ) : QGraphicsScene( parent )
{
}

void GraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent * mouseEvent )
{
	emit mousePos(mouseEvent->scenePos());
}
ich sitz da irgendwie grad auf der Leitung...

Verfasst: 27. Mai 2010 19:16
von brax
Dir fehlt das Q_OBJECT Macro in der Klasse GraphicsScene.

Verfasst: 27. Mai 2010 19:27
von jaronimo
in der tat! dankeschön! :)
da hätt ich noch stunden brauchen können, bis ich darauf gekommen wäre...