I have the QT4 example network.http working. I mean I press download and it does it.
But I want to call the download directly from the code without going through this button.

So I edited the example to remove the download button and call directly as follows :
Qt Code:
  1. quitButton = new QPushButton(tr("Quit"));
  2. // downloadButton = new QPushButton(tr("Download"));
  3. quitButton->setDefault(true);
  4.  
  5. http = new QHttp(this);
  6.  
  7. connect(http, SIGNAL(requestFinished(int, bool)),
  8. this, SLOT(httpRequestFinished(int, bool)));
  9. connect(http, SIGNAL(dataReadProgress(int, int)),
  10. this, SLOT(updateDataReadProgress(int, int)));
  11. connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
  12. this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
  13. // connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile()));
  14. connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
  15.  
  16. QHBoxLayout *buttonLayout = new QHBoxLayout;
  17. buttonLayout->addStretch(1);
  18. // buttonLayout->addWidget(downloadButton);
  19. buttonLayout->addWidget(quitButton);
  20.  
  21. QVBoxLayout *mainLayout = new QVBoxLayout;
  22. mainLayout->addLayout(buttonLayout);
  23. setLayout(mainLayout);
  24.  
  25. setWindowTitle(tr("HTTP"));
  26.  
  27. QString url = "http://api.smsbox.fr/index.php?login=ahcoeur&pass=aaaaaa&action=credit";
  28. downloadFile(url);
  29. }
  30.  
  31. void HttpWindow::downloadFile(QString mUrl)
To copy to clipboard, switch view to plain text mode 


All works well, the url is called, the download is done and the remaining Quit button screen is briefly displayed, then it crashes.

It looks like it is the return to the main event loop that aborts but why ?