Important: Please read the Qt Code of Conduct -

Beginner problem: undefined reference, Use of signals/slots

  • Hi,

    thank you already for investing time to help me finding a solution to my problem. I did research on the web and did not find any idea how to handle my errors. I do voluntary work for a youth organization and I try to help them out with making a program for easier handling with all the finance things. Since we do not have any programmer in our organization I try to deeper my knowledge and ofcourse help the group. I do have basic knowledge in C/C++.

    I try to make a GUI with which it is possible and easy!( by clicking buttons and filling in gaps) to save a new payment and later (at the end of the year) make a financial report. I wanted to use structs with IDs for every payment. The IDs should link every payment to a project and pay office. I know it is a lot of text for you to read and any kind of idea how to better my concept and my existing problems would help me to better the final product. All in all it should in the end make a nice Excel table for our chairmain.

    I did start with this code, trying to make just one button (signal slot) work and the errors appeared when building.
    The errors are in the pushbutton.cpp, line 3 and 18.
    C:\Qt\Tools...\pushbutton.cpp:3: Fehler:undefined reference to `vtable for pushbutton'

    C:\Qt\Tools...\pushbutton.cpp:18: Fehler:undefined reference to `vtable for pushbutton'

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


    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;

    class MainWindow : public QMainWindow

    explicit MainWindow(QWidget *parent = 0);

    Ui::MainWindow *ui;

    #endif // MAINWINDOW_H

    @#ifndef PUSHBUTTON_H
    #define PUSHBUTTON_H
    #include <QObject>
    #include <QString>

    class pushbutton : public QObject

    pushbutton(QObject *parent = 0);

    void createID();
    //void createExcel();
    //void showExcel();

    //public slots:
    //void setValue(int value);

    //void valueChanged(int newValue);



    #endif // pushbutton_H

    @#include "mainwindow.h"
    #include "pushbutton.h"

    #include <QApplication>

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;;
    //pushbutton cPus;
    struct structId{
    int iIDa;
    int iIDb;
    int iIDc;
    char sIDa[50];
    char sIDb[50];
    char sIDc[50];
    int ivalue;

    char sAllIDa[10][50];
    char sAllIDb[200][50];
    char sAllIDc[500][50];
                    //structId StructFirst;
    //Vorgehen mit Signals und Slots als Eventhandler
    // bei Mausklick. Diese müssen mit QObject im Programm
    // eingeführt werden. Es werden Slots, Signals und
    // die Verbindungen definiert.
    //Ein ButtonClick löst ein Signal aus, welches
    // bei einem Slot, zumeist einer function landet.
    if(1)   // Button 1 pushed. Create Exceltable
    if(2)   // Button 2 pushed. Create IDa = Projekt
    if(3)   // Button 3 pushed. Create IDb = Ausgabekategorie
    if(4)   // Button 2 pushed. Create IDc =
    if(5)   // Button 3 pushed
    return a.exec&#40;&#41;;


    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    delete ui;

    @#include "pushbutton.h"

    *pushbutton::pushbutton(QObject parent):QObject(parent)

    void pushbutton::createID()
    int iIda = 0;
    int iIdb = 0;
    int iIdc = 0;




  • Moderators

    clean your project

    rerun qmake

    build it again

Log in to reply