Undefined reference to signal
Unsolved
General and Desktop
-
Hello everyone:
Thanks for reading this post and being able to help.
I would like to create a signal to call a slot in another class.
My code looks like:
header:
class scene_mouse_event : public QGraphicsScene { Q_OBJECT public: scene_mouse_event(QObject* parent = 0); void mousePressEvent(QGraphicsSceneMouseEvent *event); QPointF pt; signals: void emit_mouse_pressed(); }; #endif // SCENE_MOUSE_EVENT_H
.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QtGui> #include <QApplication> #include "scene_mouse_event.h" scene_mouse_event::scene_mouse_event(QObject* parent): QGraphicsScene(parent){ } void scene_mouse_event::mousePressEvent(QGraphicsSceneMouseEvent *event) { this->pt = event->scenePos(); emit emit_mouse_pressed(); QGraphicsScene::mousePressEvent(event); }
but it gives me an error in "emit emit_mouse_pressed();":
scene_mouse_event.cpp:15: error: undefined reference to `scene_mouse_event::emit_mouse_pressed()'and this in the constructor:
scene_mouse_event.cpp:8: error: undefined reference to `vtable for scene_mouse_event'What's happening?
Thanks! -
hi, you need to run qmake from the build menu.
if it still stupid, then clean the build folder and rebuild all :)