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
Forum Updated to NodeBB v4.3 + New Features

Undefined reference to signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 6.4k 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.
  • A Offline
    A Offline
    AlvaroS
    wrote on 15 Jun 2016, 10:49 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 15 Jun 2016, 11:35 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

      1/2

      15 Jun 2016, 10:49

      • Login

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