PDA

View Full Version : opening webpage using qt....



anupamgee
16th April 2009, 07:47
hi all,
I hv some problem in opening the webpage using qtwebkit module..
I am using internet in a NAT environment.
i used the following code:


Widget::Widget(QWidget *parent): QWidget(parent)
{
QNetworkProxy proxy;
proxy.setHostName("10.8.58.40");
proxy.setPort(8080);
QNetworkAccessManager *manager=new QNetworkAccessManager(this);
manager->setProxy(proxy);
QUrl url;
url.setUrl("http://www.google.co.in");
QWebPage *page=new QWebPage();
page->mainFrame()->load(url);
QWebView *view = new QWebView(this);
view->setPage(page);
view->show();
}

wysota
16th April 2009, 10:43
You are created a network access manager and setting a proxy on it but QWebView never uses this object so it doesn't pick up the proxy. I'd try with QNetworkProxy::setApplicationProxy instead.

anupamgee
16th April 2009, 13:17
Thanx for reply .
can u explain this with the help of code .As i hv tried this also but didnt work for me .

wysota
17th April 2009, 09:10
I have a better idea - you explain what you did in code and I'll say what you did wrong (if anything).

anupamgee
17th April 2009, 11:20
hi,

i used this code:

#include <QApplication>
#include <QWebView>

int main(int argc, char **argv)
{
QApplication app(argc, argv);

QWebView *view = new QWebView();
view->load(QUrl("http://www.webstandards.org/files/acid2/test.html"));
view->show();

return app.exec();
}

but it is not showing the webpage.it is showing an empty widget.I want to change the proxy settings .
i tried that and i posted that code in my first post.
how to change the proxy settings of qwebview??
plzz help n tell me how to load a webpage and how to change proxy settings..

faldzip
17th April 2009, 11:25
read once again what wysota posted already... the solution is already there!

anupamgee
17th April 2009, 13:24
i used QNetworkProxy::setApplicationProxy() also. but still code doesn't work..

Widget::Widget(QWidget *parent): QWidget(parent)
{
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName("10.8.58.40");
proxy.setPort(8080);
QNetworkProxy::setApplicationProxy(proxy);
QWebView *web=new QWebView();
web->load(QUrl("http://www.google.com"));
web->show();
}

wysota
17th April 2009, 13:49
Which version of Qt do you use? Releases earlier than 4.5.0 don't use applicationwide proxy settings for WebKit. It should work in 4.5.0 (at least it had been said it would work).

anupamgee
20th April 2009, 11:13
i am using qt-sdk-2009 ,qtcreator 1.0 based on qt 4.5.........
but still it is not working.....