My code:

Qt Code:
  1. #include <QUrl>
  2.  
  3. NOTE: I run it step to step ( VS2005 debug function ).
  4.  
  5. #include <QtGui/QApplication>
  6. #include <QHttp>
  7. #include <QFile>
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11. QApplication *app=new QApplication(argc, argv);
  12. QFile *file=new QFile("index.php");
  13.  
  14. if(!file->open(QIODevice::WriteOnly)) //file create
  15. {
  16. QMessageBox::information(0,"Get User's Profile","Error: Cannot open["+file->fileName()+"] "+file->errorString());
  17. return 0;
  18. }
  19. QUrl *url=new QUrl("http://localhost/a2gold/index.php");
  20. QHttp *http=new QHttp(url->host());
  21. http->get(url->path(),file);
  22. http->close();
  23. file->flush(); //Now,file is empty
  24.  
  25. return app->exec(); //since there,file is valid(have content)
  26. }
To copy to clipboard, switch view to plain text mode 


why????

How can I get a valid(have content) file before the "return app->exec()"