hannesvdc
22nd December 2010, 21:45
I made a simple main file to test some things :
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtCore/QObject>
class application;
class UI {
public:
UI( application* a) {
app=a;
frame = new QMainWindow;
button = new QPushButton( frame );
connect( button, SIGNAL( clicked() ), this, SLOT( exit()) );
frame -> show();
}
public slots:
void exit() {
app -> exit();
}
private:
application* app;
QMainWindow* frame;
QPushButton* button;
};
class application {
public:
application( int argc, char** argv) {
qapp = new QApplication( argc, argv);
ui = new UI( this);
qapp -> exec();
}
void exit( int code = 0 ){
qapp -> exit( code );
exit( code );
}
private:
QApplication* qapp;
UI* ui;
};
int main( int argc, char** argv ){
application( argc, argv );
return 0;
}
And this are the compile errors i get:
main.cpp: In constructor ‘UI::UI(application*)’:
main.cpp:16: error: ‘connect’ was not declared in this scope
main.cpp: In member function ‘void UI::exit()’:
main.cpp:21: error: invalid use of incomplete type ‘struct application’
main.cpp:6: error: forward declaration of ‘struct application’
I'm really confused about what the problem could be.
hannesvdc
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtCore/QObject>
class application;
class UI {
public:
UI( application* a) {
app=a;
frame = new QMainWindow;
button = new QPushButton( frame );
connect( button, SIGNAL( clicked() ), this, SLOT( exit()) );
frame -> show();
}
public slots:
void exit() {
app -> exit();
}
private:
application* app;
QMainWindow* frame;
QPushButton* button;
};
class application {
public:
application( int argc, char** argv) {
qapp = new QApplication( argc, argv);
ui = new UI( this);
qapp -> exec();
}
void exit( int code = 0 ){
qapp -> exit( code );
exit( code );
}
private:
QApplication* qapp;
UI* ui;
};
int main( int argc, char** argv ){
application( argc, argv );
return 0;
}
And this are the compile errors i get:
main.cpp: In constructor ‘UI::UI(application*)’:
main.cpp:16: error: ‘connect’ was not declared in this scope
main.cpp: In member function ‘void UI::exit()’:
main.cpp:21: error: invalid use of incomplete type ‘struct application’
main.cpp:6: error: forward declaration of ‘struct application’
I'm really confused about what the problem could be.
hannesvdc