本文整理汇总了C++中QWebSettings::clearMemoryCaches方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings::clearMemoryCaches方法的具体用法?C++ QWebSettings::clearMemoryCaches怎么用?C++ QWebSettings::clearMemoryCaches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebSettings
的用法示例。
在下文中一共展示了QWebSettings::clearMemoryCaches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWebView
EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *networkManager)
: QWebView(parent)
, m_scrollParent(nullptr)
, m_resizeInProgress(0)
, m_staticWidth(0)
, m_colorScheme(ColorScheme::System)
{
// set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint!
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setFocusPolicy(Qt::StrongFocus); // not by the wheel
setPage(new ErrorCheckingPage(this));
page()->setNetworkAccessManager(networkManager);
QWebSettings *s = settings();
s->setAttribute(QWebSettings::JavascriptEnabled, false);
s->setAttribute(QWebSettings::JavaEnabled, false);
s->setAttribute(QWebSettings::PluginsEnabled, false);
s->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
s->setAttribute(QWebSettings::JavaEnabled, false);
s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false);
s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false);
s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, false);
s->clearMemoryCaches();
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
connect(this, &QWebView::linkClicked, this, &EmbeddedWebView::slotLinkClicked);
connect(this, &QWebView::loadFinished, this, &EmbeddedWebView::handlePageLoadFinished);
connect(page()->mainFrame(), &QWebFrame::contentsSizeChanged, this, &EmbeddedWebView::handlePageLoadFinished);
// Scrolling is implemented on upper layers
page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
// Setup shortcuts for standard actions
QAction *copyAction = page()->action(QWebPage::Copy);
copyAction->setShortcut(tr("Ctrl+C"));
addAction(copyAction);
m_autoScrollTimer = new QTimer(this);
m_autoScrollTimer->setInterval(50);
connect(m_autoScrollTimer, &QTimer::timeout, this, &EmbeddedWebView::autoScroll);
m_sizeContrainTimer = new QTimer(this);
m_sizeContrainTimer->setInterval(50);
m_sizeContrainTimer->setSingleShot(true);
connect(m_sizeContrainTimer, &QTimer::timeout, this, &EmbeddedWebView::constrainSize);
setContextMenuPolicy(Qt::NoContextMenu);
findScrollParent();
addCustomStylesheet(QString());
}
示例2: QWebView
EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *networkManager):
QWebView(parent), m_scrollParent(0L), m_resizeInProgress(0)
{
// set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint!
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setFocusPolicy(Qt::StrongFocus); // not by the wheel
setPage(new ErrorCheckingPage(this));
page()->setNetworkAccessManager(networkManager);
QWebSettings *s = settings();
s->setAttribute(QWebSettings::JavascriptEnabled, false);
s->setAttribute(QWebSettings::JavaEnabled, false);
s->setAttribute(QWebSettings::PluginsEnabled, false);
s->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
s->setAttribute(QWebSettings::JavaEnabled, false);
s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false);
s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false);
s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, false);
s->clearMemoryCaches();
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(slotLinkClicked(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(handlePageLoadFinished()));
connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(handlePageLoadFinished()));
// Scrolling is implemented on upper layers
page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
// Setup shortcuts for standard actions
QAction *copyAction = page()->action(QWebPage::Copy);
copyAction->setShortcut(tr("Ctrl+C"));
addAction(copyAction);
// Redmine#3, the QWebView uses black text color when rendering stuff on dark background
QPalette palette = QApplication::palette();
if (palette.background().color().lightness() < 50) {
QStyle *style = QStyleFactory::create(QLatin1String("windows"));
Q_ASSERT(style);
palette = style->standardPalette();
setPalette(palette);
}
setContextMenuPolicy(Qt::NoContextMenu);
findScrollParent();
}