1

I'm have an error in the following code. I tried to fix it with many of the options given here but could not.

Here is .h

#ifndef JUEGO2PRUEBA_H
#define JUEGO2PRUEBA_H
class juego2Prueba: public QGraphicsView
{
Q_OBJECT
public:
    juego2Prueba();
    ~juego2Prueba();
private slots:
    void on_buttonLeft_clicked();
    void on_buttonRight_clicked();
    void on_buttonUp_clicked();
    void on_buttonDown_clicked();

private:
    void mueveMomia();
    void mejorMovMomia(QChar direccion);
    void finalizaJuego();
    bool puedeMoverse(int x, int y,QChar mov);
    void creaTablero();
}

and .cpp

juego2Prueba::juego2Prueba(){
    //CODE
}

void juego2Prueba::on_buttonRight_clicked()
{//CODE}

void juego2Prueba::on_buttonLeft_clicked()
{//CODE}
void juego2Prueba::on_buttonUp_clicked()
{//code}
void juego2Prueba::on_buttonDown_clicked()
{//code}
void juego2Prueba::mueveMomia(){
//code}
void juego2Prueba::mejorMovMomia(QChar direccion){
//CODE}
void juego2Prueba::finalizaJuego(){
    this->hide();
    timerPerdio->stop();}
bool juego2Prueba::puedeMoverse(int x, int y, QChar mov){
//code}
void juego2Prueba::creaTablero(){
//more code}
juego2Prueba::~juego2Prueba(){
}

The error:

C:\Users\Barrionuevo\Desktop\build-MummyAlgoritmos-Desktop_Qt_5_6_0_MinGW_32bit-Debug\debug\juego2prueba.o:-1: In function `ZN12juego2PruebaC2Ev':
C:\Users\Barrionuevo\Desktop\MummyAlgoritmos\juego2prueba.cpp:7: error: undefined reference to `vtable for juego2Prueba'
C:\Users\Barrionuevo\Desktop\MummyAlgoritmos\juego2prueba.cpp:7: error: undefined reference to `vtable for juego2Prueba'
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Out of curiosity, did you full-clean, restart QtCreator, and full-rebuild yet ? Clarification of what "many options given here" you tried would probably help eliminate the "been there, done that" suggestions. – WhozCraig Jul 19 '16 at 04:41
  • Did you run qmake? It needs to be re-run after adding or removing signals if I'm not mistaken. – SurvivalMachine Jul 19 '16 at 05:30
  • Perhaps QGraphicsView class is not available to the linker – Martin G Jul 19 '16 at 07:08
  • I ran into the same problem. I did what @SurvivalMachine suggested which was to run qmake. Problem fixed it. – bandito40 Nov 21 '18 at 18:51

1 Answers1

0

"Undefined reference to vtable" means in qt that

  1. there is a problem with the signal slot mechanism. A signal has been sent but the reference to the slot object is invalid. So try to find out which signal/slot relation is corrupted, maybe you have never assigned a model to the view
  2. there are old compiler generated moc files which are still there. Just delete the complete debug and release folder.
Louen
  • 3,617
  • 1
  • 29
  • 49
T. Alpers
  • 46
  • 2