Important: Please read the Qt Code of Conduct -

Undefined reference to signal

  • 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:


    class scene_mouse_event : public QGraphicsScene
            scene_mouse_event(QObject* parent = 0);
            void mousePressEvent(QGraphicsSceneMouseEvent *event);
            QPointF pt;
            void emit_mouse_pressed();
    #endif // SCENE_MOUSE_EVENT_H


    #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();

    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?

  • Lifetime Qt Champion

    hi, you need to run qmake from the build menu.
    if it still stupid, then clean the build folder and rebuild all :)

Log in to reply