本文整理汇总了C++中QWebPage::networkAccessManager方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebPage::networkAccessManager方法的具体用法?C++ QWebPage::networkAccessManager怎么用?C++ QWebPage::networkAccessManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebPage
的用法示例。
在下文中一共展示了QWebPage::networkAccessManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWebView
ShibbolethWebView::ShibbolethWebView(Account* account, QWidget* parent)
: QWebView(parent)
, _account(account)
, _accepted(false)
, _cursorOverriden(false)
{
// no minimize
setWindowFlags(Qt::Dialog);
setAttribute(Qt::WA_DeleteOnClose);
QWebPage* page = new QWebPage(this);
page->setNetworkAccessManager(account->networkAccessManager());
connect(page, SIGNAL(loadStarted()),
this, SLOT(slotLoadStarted()));
connect(page, SIGNAL(loadFinished(bool)),
this, SLOT(slotLoadFinished(bool)));
connect(page->networkAccessManager()->cookieJar(),
SIGNAL(newCookiesForUrl (QList<QNetworkCookie>, QUrl)),
this, SLOT(onNewCookiesForUrl (QList<QNetworkCookie>, QUrl)));
page->mainFrame()->load(account->url());
this->setPage(page);
setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));
// If we have a valid cookie, it's most likely expired. We can use this as
// as a criteria to tell the user why the browser window pops up
QNetworkCookie shibCookie = ShibbolethCredentials::findShibCookie(_account, ShibbolethCredentials::accountCookies(_account));
if (shibCookie != QNetworkCookie()) {
Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("Your session has expired. You need to re-login to continue to use the client."));
}
}
示例2: networkAccessManager
QNetworkAccessManager* QWebPageProto::networkAccessManager() const
{
QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
if (item)
return item->networkAccessManager();
return 0;
}
示例3: settings
ShibbolethWebView::ShibbolethWebView(AccountPtr account, QWidget* parent)
: QWebView(parent)
, _account(account)
, _accepted(false)
, _cursorOverriden(false)
{
// no minimize
setWindowFlags(Qt::Dialog);
setAttribute(Qt::WA_DeleteOnClose);
QWebPage* page = new QWebPage(this);
connect(page, SIGNAL(loadStarted()),
this, SLOT(slotLoadStarted()));
connect(page, SIGNAL(loadFinished(bool)),
this, SLOT(slotLoadFinished(bool)));
// Make sure to accept the same SSL certificate issues as the regular QNAM we use for syncing
QObject::connect(page->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
_account.data(), SLOT(slotHandleSslErrors(QNetworkReply*,QList<QSslError>)));
// The Account keeps ownership of the cookie jar, it must outlive this webview.
account->lendCookieJarTo(page->networkAccessManager());
connect(page->networkAccessManager()->cookieJar(),
SIGNAL(newCookiesForUrl (QList<QNetworkCookie>, QUrl)),
this, SLOT(onNewCookiesForUrl (QList<QNetworkCookie>, QUrl)));
page->mainFrame()->load(account->url());
this->setPage(page);
setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));
// If we have a valid cookie, it's most likely expired. We can use this as
// as a criteria to tell the user why the browser window pops up
QNetworkCookie shibCookie = ShibbolethCredentials::findShibCookie(_account.data(), ShibbolethCredentials::accountCookies(_account.data()));
if (shibCookie != QNetworkCookie()) {
Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("Your session has expired. You need to re-login to continue to use the client."));
}
ConfigFile config;
QSettings settings(config.configFile());
resize(900, 700); // only effective the first time, later overridden by restoreGeometry
restoreGeometry(settings.value(ShibbolethWebViewGeometryC).toByteArray());
}
示例4: initWebViewAttributes
void MainWindow::initWebViewAttributes()
{
QWebPage* page = webView->page();
// 使用系统代理
QNetworkProxyFactory::setUseSystemConfiguration(true);
// 设置本地缓存
QNetworkDiskCache *diskCache = new QNetworkDiskCache(webView);
QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
diskCache->setCacheDirectory(location);
page->networkAccessManager()->setCache(diskCache);
page->settings()->setMaximumPagesInCache(100);
}
示例5:
static QNetworkCookieJar *cookieJar(const Document *document)
{
Frame *frame = document->frame();
if (!frame)
return 0;
FrameLoader *loader = frame->loader();
if (!loader)
return 0;
QWebFrame* webFrame = static_cast<FrameLoaderClientQt*>(loader->client())->webFrame();
QWebPage* page = webFrame->page();
QNetworkAccessManager* manager = page->networkAccessManager();
QNetworkCookieJar* jar = manager->cookieJar();
return jar;
}