[gelöst]Programm riesig nach kompilieren - QHttp schuld?
Verfasst: 11. April 2006 20:20
Habe gerade ein winziges Programm aus der c't getestet, dass eine Datei aus dem Internet herunterlädt:
pro-File (httpdownload.pro)
main.cpp
receiver.h
Nach dem Kompilieren unter Windows ist die exe-Datei 46 MB gross! Woran liegt das?
Danke für eure Antworten!
pro-File (httpdownload.pro)
Code: Alles auswählen
HEADERS= receiver.h
SOURCES= httpdownload.cpp
QT += network
unix {
MOC_DIR = .moc
OBJECTS_DIR = .obj
UI_DIR = .ui
}
!unix {
MOC_DIR = _moc
OBJECTS_DIR = _obj
UI_DIR = _ui
}
Code: Alles auswählen
#include <QApplication>
#include <QFile>
#include <QHttp>
#include <QMessageBox>
#include "receiver.h"
int main( int argc, char** argv ) {
QApplication app( argc, argv );
if( argc != 2 ) {
QMessageBox::warning( 0, "Fehler", "Aufruf: httpdownload <dateiname>" );
return -1;
}
QHttp http;
Receiver receiver( &http );
QFile targetFile( argv[1] );
if( targetFile.open( QIODevice::WriteOnly ) ) {
QObject::connect( &http, SIGNAL( done( bool ) ), &receiver, SLOT( slotDone( bool ) ) );
http.setHost( "www.ecb.int" );
http.get( "/stats/eurofxref/eurofxref-hist.xml", &targetFile );
} else {
QMessageBox::warning( 0, "Fehler", QString( "Konnte Ausgabedatei %1 nicht öffnen" ).arg( argv[1] ) );
return -2;
}
int ret = app.exec();
targetFile.close();
return ret;
}Code: Alles auswählen
#ifndef RECEIVER_H
#define RECEIVER_H
#include <QApplication>
#include <QHttp>
#include <QMessageBox>
class Receiver : public QObject
{
Q_OBJECT
public:
Receiver( QHttp* http ) : mHttp( http ) {}
public slots:
void slotDone( bool error )
{
if( error )
QMessageBox::warning( 0, "Fehler", QString( "Beim Herunterladen ist der Fehler %1 aufgetreten." ).arg( mHttp->errorString() ) );
QApplication::instance()->quit();
}
private:
QHttp* mHttp;
};
#endif /* RECEIVER_H */Danke für eure Antworten!