Hello Guys,

I'm new in QT Programming. Now i'm trying to create a simple browser in QT.
Here is my requirement in detail

1. First I need to post some content to a url
2. Need to receive it's result in text format
3. If the result is matching my actual string I need to load a url.

Posting content is working fine and I have received the result in text format.
Result matching is checking in same function too and if the result is matching the url have to load. but when I execute url is not loading.

QWebView is not working in my function. It appears for just a fraction of second and gone away. If there is anyotherway to do this please help me.


Here is my 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()
{
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"


Thanks,