Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined reference to signal

Undefined reference to signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AlvaroSA Offline
    AlvaroSA Offline
    AlvaroS
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      5

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved