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

    headers:
    -mainwindow.h
    -pushbutton.h
    sourcecode:
    -main.cpp
    -mainwindow.cpp
    -pushbutton.cpp

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    Ui::MainWindow *ui;
    };

    #endif // MAINWINDOW_H
    @

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

    class pushbutton : public QObject
    {
    Q_OBJECT

    public:
    pushbutton(QObject *parent = 0);
    ~pushbutton();

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

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

    //signals:
    //void valueChanged(int newValue);

    //private:

    };

    #endif // pushbutton_H
    @

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

    #include <QApplication>

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

    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) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    @

    @#include "pushbutton.h"

    *pushbutton::pushbutton(QObject parent):QObject(parent)
    {
    //createID();
    //Variablen

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

    }
    pushbutton::~pushbutton()
    {

    }

    @


  • Moderators

    clean your project

    rerun qmake

    build it again


Log in to reply
 

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