Here is the code.


Qt Code:
  1. #include <QApplication>
  2. #include <QtWebKit>
  3. #include <QNetworkProxy>
  4. #include <QtGui>
  5. #include <QNetworkInterface>
  6. #include <QString>
  7. #include <QList>
  8. #include <QNetworkAccessManager>
  9. #include <QNetworkRequest>
  10. #include <QNetworkReply>
  11. #include <QStringList>
  12. #include <QUrl>
  13. #define STR_EQUAL 0
  14.  
  15. class DownloadManager: public QObject
  16. {
  17. Q_OBJECT
  18. QNetworkAccessManager manager;
  19. public:
  20. public slots:
  21. void execute();
  22. void downloadFinished(QNetworkReply *reply);
  23. };
  24. void DownloadManager::execute()
  25. {
  26. QString text;
  27. QString arg1;
  28. arg1 = "http://example.com";
  29. QUrl url = QUrl::fromEncoded(arg1.toLocal8Bit());
  30. QNetworkRequest request(url);
  31. connect(&manager, SIGNAL(finished(QNetworkReply*)),
  32. SLOT(downloadFinished(QNetworkReply*)));
  33. QNetworkReply *reply = manager.get(request);
  34. }
  35.  
  36. void DownloadManager::downloadFinished(QNetworkReply *reply)
  37. {
  38. QString val1=reply->readAll(); //Receiving url result after get
  39. QString return_value="xxxxxxxxxxxx"; //text for comparing result of get
  40. QWebView view;
  41. if (QString::compare(val1.toAscii().constData(), return_value) == STR_EQUAL) // Checking strings are matching or not
  42. {
  43. view.load(QUrl("http://google.com")); //Url that has to be appear in browser
  44. view.show();
  45. }
  46. }
  47.  
  48. int main(int argc, char **argv)
  49. {
  50. QApplication app(argc, argv);
  51. DownloadManager manager;
  52. manager.execute();
  53. return app.exec();
  54. QApplication::instance()->quit();
  55. }
  56. #include "main.moc"
To copy to clipboard, switch view to plain text mode