ich moechte diverse Funktionen in eigene Klassen auslagern. Ich habe eine von QDialog abgeleitete Klasse "testapp", von testapp leite ich eine Klasse "add" ab die spaeter mal gewisse Funktionen haben soll. Die Klasse add hat einen slot "calcualte_add" den ich mit dem Button "add" ueber eine connect Anweisung verbunden habe. Leider wird der Slot nicht gerufen wenn ich den "add" Button druecke. Warum? Ich habe das gleiche nochmal mit "sub" welches nicht in einer eigenen Klasse ist, hier funktionierts. Habe wohl irgendwas mit der Vererbung vergessen...
Hier der code von testapp.cpp
Code: Alles auswählen
#include "testapp.h"
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QValidator>
#include <QString>
#include <cmath>
#include <iostream>
#include <QMessageBox>
using namespace std;
class add : public testapp{
public:
private slots:
void calculate_add();
};
void add::calculate_add(){
qDebug() << "calling method calculate_add";
c1 -> setText("add");
// add a and b and display in c
return;
}
testapp::testapp(QMainWindow *parent) : QMainWindow(parent){
setupUi(this);
// setup connections
connect(actionQuit,SIGNAL (triggered()), this, SLOT(slotClose()));
connect(add,SIGNAL (clicked()), this, SLOT(calculate_add()));
connect(sub,SIGNAL (clicked()), this, SLOT(calculate_sub()));
connect(actionA,SIGNAL (triggered()), this, SLOT(page_add()));
connect(actionSub,SIGNAL (triggered()), this, SLOT(page_sub()));
}
testapp::~testapp(){
}
void testapp::page_sub(){
stackedWidget -> setCurrentIndex(1);
return;
}
void testapp::page_add(){
stackedWidget -> setCurrentIndex(0);
return;
}
void testapp::calculate_sub(){
c2 -> setText("sub");
// sub a and b and dispay in c
return;
}
void testapp::slotClose(){
close();
}
J.