I did what you told, and the errors that had to do with 'connect' are gone. I also moved the
function bodies outside the class declarations, but i still get this error:
main.cpp: In member function ‘void UI::exit()’:
main.cpp:30: error: invalid use of incomplete type ‘struct application’
main.cpp:6: error: forward declaration of ‘struct application’
main.cpp: In member function ‘void UI::exit()’:
main.cpp:30: error: invalid use of incomplete type ‘struct application’
main.cpp:6: error: forward declaration of ‘struct application’
To copy to clipboard, switch view to plain text mode
This is the code:
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtCore/QObject>
class application;
Q_OBJECT
public:
UI( application* );
public slots:
void exit();
private:
application* app;
};
UI::UI( application* a ){
app = a;
connect( button, SIGNAL( clicked() ), this, SLOT( exit()) );
frame -> show();
}
void UI::exit( ) {
app->exit();
}
/*******************************************************************/
class application {
public:
application( int , char** ) ;
void exit( int = 0 );
private:
UI* ui;
};
application::application( int argc, char** argv) {
ui = new UI( this);
qapp -> exec();
}
void application::exit( int code ){
qapp->exit(code);
exit(code);
}
/******************************************************************/
int main( int argc, char** argv ){
application( argc, argv );
return 0;
}
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtCore/QObject>
class application;
class UI : public QObject {
Q_OBJECT
public:
UI( application* );
public slots:
void exit();
private:
application* app;
QMainWindow* frame;
QPushButton* button;
};
UI::UI( application* a ){
app = a;
frame = new QMainWindow;
button = new QPushButton( frame );
connect( button, SIGNAL( clicked() ), this, SLOT( exit()) );
frame -> show();
}
void UI::exit( ) {
app->exit();
}
/*******************************************************************/
class application {
public:
application( int , char** ) ;
void exit( int = 0 );
private:
QApplication* qapp;
UI* ui;
};
application::application( int argc, char** argv) {
qapp = new QApplication( argc, argv);
ui = new UI( this);
qapp -> exec();
}
void application::exit( int code ){
qapp->exit(code);
exit(code);
}
/******************************************************************/
int main( int argc, char** argv ){
application( argc, argv );
return 0;
}
To copy to clipboard, switch view to plain text mode
hannesvdc
Bookmarks