#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->textEdit->append("Updating response now.");
QUrl a("http://google.co.in");
manager = new QNetworkAccessManager(this);
// QNetworkProxyQuery npq(a);
// QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
// QNetworkProxy pr = listOfProxies.at(0);
// qDebug() << "Count: " << pr.hostName();
// if (listOfProxies.count() !=0){
// if (listOfProxies.at(0).type() != QNetworkProxy::NoProxy) {
// manager->setProxy(listOfProxies.at(0));
// qDebug() << "listOfProxies.at(0).hostName().toStdString()" ;
//// qDebug() << "Using Proxy " << listOfProxies.at(0).hostName().toStdString();
// }
// }
connect(manager,SIGNAL(finished(QNetworkReply*)),t his,SLOT(doneSlot(QNetworkReply*)));
// QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy,"http://Proxy.TechM/wpad.dat",80);
// manager->setProxy(proxy);
QNetworkReply *reply = manager->get(QNetworkRequest(a));
reply->waitForReadyRead(-1);
qDebug() << reply->readAll().data();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::doneSlot(QNetworkReply *reply)
{
ui->textEdit->append("Reading reply now");
QString response = reply->readAll().data();
ui->textEdit->append(response);
}
Bookmarks