fengtian.we
24th May 2007, 09:16
:confused:
My code:
#include <QUrl>
NOTE: I run it step to step ( VS2005 debug function ).
#include <QtGui/QApplication>
#include <QHttp>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication *app=new QApplication(argc, argv);
QFile *file=new QFile("index.php");
if(!file->open(QIODevice::WriteOnly)) //file create
{
QMessageBox::information(0,"Get User's Profile","Error: Cannot open["+file->fileName()+"] "+file->errorString());
return 0;
}
QUrl *url=new QUrl("http://localhost/a2gold/index.php");
QHttp *http=new QHttp(url->host());
http->get(url->path(),file);
http->close();
file->flush(); //Now,file is empty
return app->exec(); //since there,file is valid(have content)
}
why????
How can I get a valid(have content) file before the "return app->exec()"
My code:
#include <QUrl>
NOTE: I run it step to step ( VS2005 debug function ).
#include <QtGui/QApplication>
#include <QHttp>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication *app=new QApplication(argc, argv);
QFile *file=new QFile("index.php");
if(!file->open(QIODevice::WriteOnly)) //file create
{
QMessageBox::information(0,"Get User's Profile","Error: Cannot open["+file->fileName()+"] "+file->errorString());
return 0;
}
QUrl *url=new QUrl("http://localhost/a2gold/index.php");
QHttp *http=new QHttp(url->host());
http->get(url->path(),file);
http->close();
file->flush(); //Now,file is empty
return app->exec(); //since there,file is valid(have content)
}
why????
How can I get a valid(have content) file before the "return app->exec()"