Here is the code.
#include <QApplication>
#include <QtWebKit>
#include <QNetworkProxy>
#include <QtGui>
#include <QNetworkInterface>
#include <QString>
#include <QList>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QStringList>
#include <QUrl>
#define STR_EQUAL 0
class DownloadManager
: public QObject{
Q_OBJECT
QNetworkAccessManager manager;
public:
public slots:
void execute();
void downloadFinished(QNetworkReply *reply);
};
void DownloadManager::execute()
{
arg1 = "http://example.com";
QUrl url
= QUrl::fromEncoded(arg1.
toLocal8Bit());
QNetworkRequest request(url);
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(downloadFinished(QNetworkReply*)));
QNetworkReply *reply = manager.get(request);
}
void DownloadManager::downloadFinished(QNetworkReply *reply)
{
QString val1
=reply
->readAll
();
//Receiving url result after get QString return_value
="xxxxxxxxxxxx";
//text for comparing result of get QWebView view;
if (QString::compare(val1.
toAscii().
constData(), return_value
) == STR_EQUAL
) // Checking strings are matching or not {
view.
load(QUrl("http://google.com"));
//Url that has to be appear in browser view.show();
}
}
int main(int argc, char **argv)
{
DownloadManager manager;
manager.execute();
return app.exec();
}
#include "main.moc"
#include <QApplication>
#include <QtWebKit>
#include <QNetworkProxy>
#include <QtGui>
#include <QNetworkInterface>
#include <QString>
#include <QList>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QStringList>
#include <QUrl>
#define STR_EQUAL 0
class DownloadManager: public QObject
{
Q_OBJECT
QNetworkAccessManager manager;
public:
public slots:
void execute();
void downloadFinished(QNetworkReply *reply);
};
void DownloadManager::execute()
{
QString text;
QString arg1;
arg1 = "http://example.com";
QUrl url = QUrl::fromEncoded(arg1.toLocal8Bit());
QNetworkRequest request(url);
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(downloadFinished(QNetworkReply*)));
QNetworkReply *reply = manager.get(request);
}
void DownloadManager::downloadFinished(QNetworkReply *reply)
{
QString val1=reply->readAll(); //Receiving url result after get
QString return_value="xxxxxxxxxxxx"; //text for comparing result of get
QWebView view;
if (QString::compare(val1.toAscii().constData(), return_value) == STR_EQUAL) // Checking strings are matching or not
{
view.load(QUrl("http://google.com")); //Url that has to be appear in browser
view.show();
}
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
DownloadManager manager;
manager.execute();
return app.exec();
QApplication::instance()->quit();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks