Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Undefined reference to vtable



  • Hello,

    I added a form named "Suchen" and declared it in the suchen.h & suchen.cpp files.
    During the compiling I have become a failure which I couldnt understand.
    I added the "suchen.h" and suchen.cpp files. Do someone have an idea ?

    Thanks,

    the header file :

    #ifndef SUCHEN_H
    #define SUCHEN_H
    
    #include <QtSql>
    #include <QtGui>
    #include <QDialog>
    
    
    namespace Ui {
    class Suchen;
    }
    
    class Suchen : public QDialog
    {
        Q_OBJECT
    
    public:
        explicit Suchen(QWidget *parent = 0);
        ~Suchen();
    
    
    
    public:
          //void suchenliste();
          bool dbVerbinden();
    
    public:
          QString sqlAbfrage;
          QString suchen1;
    
    
    private slots:
        void on_SucheStart_clicked();
        void on_SucheBeenden_clicked();
    
    
    private:
        Ui::Suchen *ui;
    
        //steht die Verbindung zur Datenbank?
        bool dbVerbunden;
    
        //für die Datenbank
        QSqlDatabase datenbank;
    
    };
    
    
    
    #endif // SUCHEN_H
    
    

    the cpp file :

    #include "suchen.h"
    #include "ui_suchen.h"
    //#include "suchenliste.h"
    
    
    #include <QtSql>
    #include <QTableView>
    #include <QMessageBox>
    #include <QInputDialog>
    
    //der Konstruktor
    //er verbindet das Formular mit der Oberfläche und stellt die Verbindungen her
    
    
    Suchen::Suchen(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Suchen)
    {
        ui->setupUi(this);
        //dbVerbunden = dbVerbinden();
    }
    
    
    
    Suchen::~Suchen()
    {
        delete ui;
    }
    
    
    


  • @cprogcoder said in Undefined reference to vtable:

    private slots:
    void on_SucheStart_clicked();
    void on_SucheBeenden_clicked();

    Hi @cprogcoder

    The cause of your problem is that you did not add definition of your slots on your cpp files

    private slots:
        void on_SucheStart_clicked();
        void on_SucheBeenden_clicked();
    

    this should solve the problem:

    void Suchen::on_SucheStart_clicked()
    {
    
    }
    
    void Suchen::on_SucheBeenden_clicked()
    {
    
    }
    

    I hope this can help you !


  • Lifetime Qt Champion

    Hi
    Clean the build folder (delete it)
    run qmake
    and rebuild all and it should work.

    @mostefa
    Good catch. completely missed that.



  • Hello,
    I tried the suggestions, now it works fine.
    Thank you in advance,



  • @cprogcoder Please use the button "Topic Tools" and mark this thread as solved.


Log in to reply