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. Error: undefined reference to `vtable for <class>'
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.0k 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.
  • D Offline
    D Offline
    Dropye
    wrote on last edited by
    #1

    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 to vtable 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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      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() {}
      @

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

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