Error: undefined reference to `vtable for <class>'



  • Hey there,

    I searched a bit to find a solution by myself but cant find anything what is solving my problem.

    I work on this Project for 4 weeks now and today it suddenly stopped compiling proberly.

    This is the full error I get:

    bq. D:\Qt\Tools\QtCreator\bin\SE_Beleg\SE_Beleg\View\source\dialog_mainlehr.cpp:3: Fehler: undefined reference to vtable for Dialog_MainLehr' D:\Qt\Tools\QtCreator\bin\SE_Beleg\SE_Beleg\View\source\dialog_mainlehr.cpp:3: Fehler: undefined reference tovtable for Dialog_MainLehr'

    collect2.exe:-1: Fehler: error: ld returned 1 exit status

    And this are my files:

    .pro
    @#-------------------------------------------------

    Project created by QtCreator 2014-05-28T12:54:33

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = SE_Beleg
    TEMPLATE = app

    SOURCES += View/source/main.cpp
    View/source/dialog_mainansicht.cpp
    View/source/dialog_mainstudent.cpp
    View/source/dialog_gruppeanlegen.cpp
    View/source/dialog_about.cpp
    View/source/dialog_msg.cpp
    View/source/dialog_mainlehr.cpp
    View/source/dialog_login.cpp

    HEADERS += View/header/dialog_mainansicht.h
    View/header/dialog_mainstudent.h
    View/header/dialog_gruppeanlegen.h
    View/header/dialog_about.h
    View/header/dialog_msg.h
    View/header/dialog_mainlehr.h
    View/header/dialog_login.h
    Controller/Archiv.h
    Controller/Belegarbeit.h
    Controller/Gruppe.h
    Controller/Handler.h
    Controller/HandlerGruppeAnlegen.h
    Controller/HandlerLehrkraft.h
    Controller/HandlerStudent.h
    Controller/Passwort.h
    Controller/Rollen.h
    Controller/Student.h
    Controller/Thema.h
    Controller/DBGruppe.h
    Controller/DBGruppeAnlegen.h
    Controller/DBLehrkraft.h
    Controller/DBPasswort.h
    Controller/DBService.h

    FORMS += View/Qt_Files/dialog_mainansicht.ui
    View/Qt_Files/dialog_mainstudent.ui
    View/Qt_Files/dialog_gruppeanlegen.ui
    View/Qt_Files/dialog_about.ui
    View/Qt_Files/dialog_msg.ui
    View/Qt_Files/dialog_login.ui
    @

    dialog_mainlehr.h

    @
    #ifndef DIALOG_MAINLEHR_H
    #define DIALOG_MAINLEHR_H

    #include "dialog_mainansicht.h"

    class Dialog_MainLehr : public Dialog_MainAnsicht
    {
    public:
    Dialog_MainLehr();
    void CreateActions();

    public slots:
    virtual void OnClickItem();
    };

    #endif // DIALOG_MAINLEHR_H
    @

    dialog_mainlehr.cpp

    @#include "../header/dialog_mainlehr.h"

    Dialog_MainLehr::Dialog_MainLehr()
    {
    FillTree(Handler->GetBelegarbeit());
    CreateActions();
    }

    void Dialog_MainLehr::CreateActions()
    {
    QAction *Student = action_email_senden_an_Student;
    char tmp[255];

    std::vector<CBelegarbeit> *Belegarbeiten = Handler->GetBelegarbeit();
    
    for(unsigned int i = 0; i < Belegarbeiten->size(); i++)
    {
        CBelegarbeit *BA = &(Belegarbeiten)->at(i);
        std::vector<CGruppe> * Gruppen = BA->GetGruppen();
        for(unsigned int j = 0; j < Gruppen->size(); j++)
        {
            CGruppe *GR = &(Gruppen)->at(j);
            std::vector<CStudent> *Studenten = GR->GetStudenten();
            for(unsigned int k = 0; k < Studenten->size(); k++)
            {
                CStudent * ST = &(Studenten)->at(k);
                QAction *newAct = new QAction(Student);
    
                sprintf(tmp, "%s, %s, %s", ST->GetSNummer().c_str(), ST->GetVorname().c_str(), ST->GetNachname().c_str());
                newAct->setText(QString(tmp));
            }
        }
    }
    

    }
    @

    I forced a qMake manually, I forced a complete rebuild and the header is in the .pro file.

    So what could be wrong?

    lg

    Dropye



  • Do you have all virtual function defined for Dialog_MainLehr and for Dialog_MainAnsicht?

    Is Dialog_MainAnsicht derived from QDialog?

    Try to add the following line to the Dialog_MainLehr class declaration
    @
    virtual ~Dialog_MainLehr() {}
    @


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It might also happen if you add/remove the QObject macro and forget to re-run qmake before building


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.