/* main */
WebView* view = new WebView (this);
view
->load
(QUrl("http://www.mySite.com"));
: QWebView(parent)
, m_page(new WebPage(this))
{
setPage(m_page);
}
: QWebPage(parent)
{
setNetworkAccessManager(/*networkAccessManager*/);
}
networkManager
::networkManager(QWidget *parent
): QNetworkAccessManager(parent)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SLOT(authentication_required(QNetworkReply*,QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
SLOT(proxy_authentication_required(const QNetworkProxy&, QAuthenticator*)));
/* create and set proxy */
"my-proxy",
8080,
user_name,
user_password);
setProxy(proxy);
}
void networkManager::proxy_authentication_required
(
QAuthenticator *authenticator
)
{
/* create a dialog to allow user to type usename and password */
authenticator->setUser(/*username*/);
authenticator->setPassword(/*password*/);
}
/* main */
WebView* view = new WebView (this);
view->load(QUrl("http://www.mySite.com"));
WebView::WebView(QWidget *parent)
: QWebView(parent)
, m_page(new WebPage(this))
{
setPage(m_page);
}
WebPage::WebPage(QObject *parent)
: QWebPage(parent)
{
setNetworkAccessManager(/*networkAccessManager*/);
}
networkManager::networkManager(QWidget *parent)
: QNetworkAccessManager(parent)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SLOT(authentication_required(QNetworkReply*,QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
SLOT(proxy_authentication_required(const QNetworkProxy&, QAuthenticator*)));
/* create and set proxy */
QNetworkProxy proxy(QNetworkProxy::HttpProxy,
"my-proxy",
8080,
user_name,
user_password);
setProxy(proxy);
}
void networkManager::proxy_authentication_required
(
const QNetworkProxy &proxy,
QAuthenticator *authenticator
)
{
/* create a dialog to allow user to type usename and password */
authenticator->setUser(/*username*/);
authenticator->setPassword(/*password*/);
}
To copy to clipboard, switch view to plain text mode
Bookmarks