C++ (Qt)QNetworkReply * QNetworkAccessManager::get ( const QNetworkRequest & request )
C++ (Qt)QString MainWindow::DoRequest(QUrl url,QString method,QByteArray post_data){ QNetworkAccessManager *manager = new QNetworkAccessManager; QNetworkReply* reply; if(method == "GET") { connect(manager, SIGNAL(finished(QNetworkReply *)), SLOT(requestFinished(QNetworkReply*))); reply = manager->get(QNetworkRequest(url)); QByteArray arr = reply->readAll(); return (QString)arr; } else Beep(100,100);} void MainWindow::requestFinished(QNetworkReply* reply){ QFile file("C:\\file.htm"); if (file.open(QIODevice::WriteOnly)) { file.write(reply->readAll()); file.flush(); file.close(); }}
reply = manager->get(QNetworkRequest(url));QByteArray arr = reply->readAll();
/* Create the QEventLoop */QEventLoop pause;/* connect the QHttp.requestFinished() Signal to the QEventLoop.quit() Slot */connect(&login, SIGNAL(requestFinished( int, bool )), &pause, SLOT(quit()));/* The code that will run during the QEventLoop */login.request(header,&logmein,&result);/* Execute the QEventLoop - it will quit when the above finished due to the connect() */pause.exec();