0

Everytime i click my QPushButton which I have added with the UI Designer, the button stays clicked and the application crashes. When I remove the slot which the 'clicked()' signal of the button is connected to, I can click the button and the application behaves normal.

This is the header of the class that uses the UI:

#ifndef DARLEHENSRECHNER_H
#define DARLEHENSRECHNER_H

#include <QMainWindow>
#include "Darlehensgeber.h"

namespace Ui {
    class Darlehensrechner;
}

class Darlehensrechner : public QMainWindow
{
    Q_OBJECT

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

private slots:
    void on_berechnenButton_clicked();

private:
        Ui::Darlehensrechner *ui;
        Darlehensgeber dg;
};

#endif // DARLEHENSRECHNER_H

And this is the cpp:

#include "darlehensrechner.h"
#include "ui_darlehensrechner.h"

Darlehensrechner::Darlehensrechner(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Darlehensrechner),
    dg()
{
    ui->setupUi(this);
}

Darlehensrechner::~Darlehensrechner()
{
    delete ui;
}

void Darlehensrechner::on_berechnenButton_clicked()
{
    dg.takeLoan(ui->kreditEdit->text().toFloat(),
                ui->ratenEdit->text().toFloat(),
                ui->zinsEdit->text().toFloat());

    ui->dauerLabel_2->setText(QString::number(dg.getAmountOfInstallments()));
    ui->betragLabel_2->setText(QString::number(dg.getAmount()));
}

0 Answers0