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. Beginner problem: undefined reference, Use of signals/slots
Qt 6.11 is out! See what's new in the release blog

Beginner problem: undefined reference, Use of signals/slots

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.1k 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.
  • F Offline
    F Offline
    Flattattatat
    wrote on last edited by
    #1

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

    }

    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      clean your project

      rerun qmake

      build it again

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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