analog wie im Thread "Subclassing" beschrieben habe ich mal versucht mein erstes Qt4 Programm zu schreiben. Ich habe im Designer ein File testapp.ui angelegt. Es ist die Standardform "Dialog mit Button unten", sonst nix.
Des weiteren habe ich von Hand das folgende gemacht:
1. uic -o ui_testapp.h testapp.ui aufgerufen
2. main.cpp
Code: Alles auswählen
#include <QtCore>
#include "QtGui"
#include "testapp.h"
int main( int argc, char* argv[]){
QApplication a(argc, argv);
TestApp w;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()),a&, SLOT(quit()));
return a.exec();
}
Code: Alles auswählen
#ifndef TESTAPP_H
#define TESTAPP_H
#include "ui_testapp.h"
#include <QtGui>
#include <QtCore>
class TestApp : public QWidget, public Ui::TestApp{
Q_OBJECT
public:
TestApp (QWidget *parent = 0);
~TestApp();
private slots:
void slotClose();
};
#endif //TESTAPP_H
Code: Alles auswählen
#include "testapp.h"
#include <QtGui>
#include <QtCore>
TestApp::TestApp(QWidget *parent) : QWidget(parent)
{
setupUi(this);
connect(okButton, SIGNAL (clicked()), this, SLOT(slotClose()));
}
TestApp::~TestApp()
{}
void TestApp::slotClose()
{
qApp->quit();
}
6. qmake
7. make
Nun bekomme ich den folgenden Fehler:
guest@linux:~/Desktop/testapp> make
g++ -c -pipe -fno-strict-aliasing -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/default -I. -I/usr/include/QtGui -I/usr/include/QtCore -I/usr/include -I. -I. -I. -o main.o main.cpp
testapp.h:9: error: expected class-name before ‘{’ token
main.cpp: In function ‘int main(int, char**)’:
main.cpp:10: error: expected primary-expression before ‘,’ token
make: *** [main.o] Error 1
Ich kann leider nicht sehen was falsch ist. Wer kann helfen?
Danke,
J.