本文整理汇总了C++中QWebSettings类的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings类的具体用法?C++ QWebSettings怎么用?C++ QWebSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName(app.translate("main", "Matrix Quiz"));
#ifdef Q_WS_MAC
app.setCursorFlashTime(0);
#endif
qsrand(static_cast<uint>(time(0)));
QWebSettings *webSettings = QWebSettings::globalSettings();
webSettings->setAttribute(QWebSettings::AutoLoadImages, true);
webSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
webSettings->setAttribute(QWebSettings::PluginsEnabled, true);
QString url = QUrl::fromLocalFile(AQP::applicationPathOf() +
"/matrixquiz.html").toString();
BrowserWindow *browser = new BrowserWindow(url, new WebPage);
browser->showToolBar(false);
browser->enableActions(false);
QDialogButtonBox *buttonBox = new QDialogButtonBox;
QPushButton *quitButton = buttonBox->addButton(
app.translate("main", "&Quit"),
QDialogButtonBox::AcceptRole);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(browser, 1);
layout->addWidget(buttonBox);
QDialog dialog;
dialog.setLayout(layout);
QObject::connect(quitButton, SIGNAL(clicked()),
&dialog, SLOT(accept()));
dialog.setWindowTitle(app.applicationName());
dialog.show();
return app.exec();
}
示例2: QMainWindow
LoginForm::LoginForm(QUrl url, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::LoginForm)
{
url.addEncodedQueryItem(OAUTH_CALLBACK,QByteArray(REDIRECT_URL).toPercentEncoding());
qDebug() << url;
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5AutoOrientation);
setAttribute(Qt::WA_Maemo5StackedWindow);
#endif
QWebSettings* defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
defaultSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
ui->setupUi(this);
// defaultSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled,true);
page = new JsConsoleWebPage(this);
ui->webView->setPage(page);
QWebViewSelectionSuppressor *suppressor = new QWebViewSelectionSuppressor(ui->webView);
suppressor->enable();
ui->webView->setInputMethodHints(Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText);
connect(page,SIGNAL(consoleMessage(QString)),this,SLOT(consoleMessage(QString)));
connect(ui->webView, SIGNAL(urlChanged(QUrl)), this, SLOT(handleChange(QUrl)));
ui->webView->load(url);
}
示例3: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
config_(kimai::paths::dataFolder() + "Config.ini") {
ui->setupUi(this);
configDialog_ = NULL;
setWindowTitle("Kimai");
QWebSettings* webSettings = QWebSettings::globalSettings();
webSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
jsBridge_ = new KimaiJavaScriptBridge(this);
connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(webView_loadFinished(bool)));
connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(mainFrame_javaScriptWindowObjectCleared()));
connect(ui->actionConfiguration, SIGNAL(triggered()), this, SLOT(menuBar_configuration_triggered()));
connect(&config_, SIGNAL(valueChanged(QString)), this, SLOT(config_valueChanged(QString)));
QVariant kimaiUrl = config_.value("kimaiUrl");
if (kimaiUrl.isNull() || kimaiUrl.toString().trimmed().isEmpty()) {
QMessageBox::information(this, "Kimai URL not set", "No Kimai URL set. Please set it in the configuration dialog.");
showConfigDialog();
} else {
ui->webView->load(QUrl(kimaiUrl.toString()));
}
QSettings settings("Kimai", "Kimai Desktop Client");
QVariant geometry = settings.value("kimai/windowGeometry");
if (!geometry.isNull()) restoreGeometry(geometry.toByteArray());
}
示例4: QFont
void SettingsDialog::loadDefaults()
{
QWebSettings *defaultSettings = QWebSettings::globalSettings();
QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
m_standardFont = QFont(standardFontFamily, standardFontSize);
standardLabel->setText(QString(QLatin1String("%1 %2")).arg(m_standardFont.family()).arg(m_standardFont.pointSize()));
QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
m_fixedFont = QFont(fixedFontFamily, fixedFontSize);
fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(m_fixedFont.family()).arg(m_fixedFont.pointSize()));
downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
blockPopupWindows->setChecked(!defaultSettings->testAttribute(QWebSettings::JavascriptCanOpenWindows));
enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled));
enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled));
enableImages->setChecked(defaultSettings->testAttribute(QWebSettings::AutoLoadImages));
enableLocalStorage->setChecked(defaultSettings->testAttribute(QWebSettings::LocalStorageEnabled));
clickToFlash->setChecked(false);
cookieSessionCombo->setCurrentIndex(0);
filterTrackingCookiesCheckbox->setChecked(false);
autoFillPasswordFormsCheckBox->setChecked(false);
minimFontSizeCheckBox->setChecked(false);
minimumFontSizeSpinBox->setValue(9);
}
示例5: saveSession
void BrowserApplication::saveSession()
{
if (quiting)
return;
QSettings settings;
settings.beginGroup(QLatin1String("MainWindow"));
settings.setValue(QLatin1String("restoring"), false);
settings.endGroup();
QWebSettings *globalSettings = QWebSettings::globalSettings();
if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
return;
clean();
settings.beginGroup(QLatin1String("sessions"));
int version = 2;
QByteArray data;
QBuffer buffer(&data);
QDataStream stream(&buffer);
buffer.open(QIODevice::WriteOnly);
stream << qint32(BrowserApplicationMagic);
stream << qint32(version);
stream << qint32(m_mainWindows.count());
for (int i = 0; i < m_mainWindows.count(); ++i)
stream << m_mainWindows.at(i)->saveState();
settings.setValue(QLatin1String("lastSession"), data);
settings.endGroup();
}
示例6: if
void LayoutTestController::overridePreference(const QString& name, const QVariant& value)
{
QWebSettings* settings = m_topLoadingFrame->page()->settings();
if (name == "WebKitJavaScriptEnabled")
settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool());
else if (name == "WebKitTabToLinksPreferenceKey")
settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool());
else if (name == "WebKitOfflineWebApplicationCacheEnabled")
settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool());
else if (name == "WebKitDefaultFontSize")
settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt());
else if (name == "WebKitUsesPageCachePreferenceKey")
QWebSettings::setMaximumPagesInCache(value.toInt());
else if (name == "WebKitEnableCaretBrowsing")
setCaretBrowsingEnabled(value.toBool());
else if (name == "WebKitPluginsEnabled")
settings->setAttribute(QWebSettings::PluginsEnabled, value.toBool());
else if (name == "WebKitWebGLEnabled")
settings->setAttribute(QWebSettings::WebGLEnabled, value.toBool());
else if (name == "WebKitCSSRegionsEnabled")
settings->setAttribute(QWebSettings::CSSRegionsEnabled, value.toBool());
else if (name == "WebKitHyperlinkAuditingEnabled")
settings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, value.toBool());
else if (name == "WebKitHixie76WebSocketProtocolEnabled")
DumpRenderTreeSupportQt::setHixie76WebSocketProtocolEnabled(m_topLoadingFrame->page(), value.toBool());
else if (name == "WebKitAcceleratedCompositingEnabled")
settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, value.toBool());
else
printf("ERROR: LayoutTestController::overridePreference() does not support the '%s' preference\n",
name.toLatin1().data());
}
示例7: QWebView
itsBrowser::itsBrowser( QWidget *parent ) :
QWebView( parent ){
//This is needed in Ubuntu under QT 5 for SSL to work
//Still need to test in Windows7
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
sslConfig.setProtocol( QSsl::SslV3 ); //Seems under ubuntu we need to specify the version
QSslConfiguration::setDefaultConfiguration( sslConfig );
QWebSettings *Tsettings = settings();
Tsettings->setAttribute( QWebSettings::JavascriptEnabled , true );
Tsettings->setAttribute( QWebSettings::PluginsEnabled , true );
Tsettings->setAttribute( QWebSettings::AutoLoadImages , true );
Tsettings->setAttribute( QWebSettings::JavaEnabled , true );
Tsettings->setAttribute( QWebSettings::JavascriptCanOpenWindows , true);
QNetworkCookieJar *myjar = new QNetworkCookieJar();
this->page()->networkAccessManager()->setCookieJar(myjar);
connect( page()->networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, const QList<QSslError> & ) ) ,this,SLOT( handleSslErrors( QNetworkReply*, const QList<QSslError> & ) ) );
connect( page()->networkAccessManager(), SIGNAL( authenticationRequired( QNetworkReply*,QAuthenticator* ) ) , this,SLOT( ProvideAuthentication(QNetworkReply*,QAuthenticator* ) ) );
connect( page()->networkAccessManager(), SIGNAL( proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)) , this , SLOT( ProvideProxAuthentication( const QNetworkProxy&, QAuthenticator*) ) );
connect( page()->networkAccessManager(), SIGNAL( finished ( QNetworkReply *)),this,SLOT(NetworkTaskfinished (QNetworkReply *)));
}
示例8: QFileIconProvider
void DownloadManager::updateRow()
{
DownloadItem *item = qobject_cast<DownloadItem*>(sender());
int row = m_downloads.indexOf(item);
if (-1 == row)
return;
if (!m_iconProvider)
m_iconProvider = new QFileIconProvider();
QIcon icon = m_iconProvider->icon(item->m_output.fileName());
if (icon.isNull())
icon = style()->standardIcon(QStyle::SP_FileIcon);
item->fileIcon->setPixmap(icon.pixmap(48, 48));
downloadsView->setRowHeight(row, item->minimumSizeHint().height());
bool remove = false;
QWebSettings *globalSettings = QWebSettings::globalSettings();
if (!item->downloading()
&& globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
remove = true;
if (item->downloadedSuccessfully()
&& removePolicy() == DownloadManager::SuccessFullDownload) {
remove = true;
}
if (remove)
m_model->removeRow(row);
cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0);
}
示例9: sipReleaseType
static PyObject *meth_QWebSettings_setFontFamily(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QWebSettings::FontFamily a0;
const QString* a1;
int a1State = 0;
QWebSettings *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BEJ1", &sipSelf, sipType_QWebSettings, &sipCpp, sipType_QWebSettings_FontFamily, &a0, sipType_QString,&a1, &a1State))
{
sipCpp->setFontFamily(a0,*a1);
sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QWebSettings, sipName_setFontFamily, doc_QWebSettings_setFontFamily);
return NULL;
}
示例10: lineEdit
void ToolbarSearch::searchNow()
{
QString searchText = lineEdit()->text();
QStringList newList = m_stringListModel->stringList();
if (newList.contains(searchText))
newList.removeAt(newList.indexOf(searchText));
newList.prepend(searchText);
if (newList.size() >= m_maxSavedSearches)
newList.removeLast();
QWebSettings *globalSettings = QWebSettings::globalSettings();
if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
m_stringListModel->setStringList(newList);
m_autosaver->changeOccurred();
}
QUrl url(QLatin1String("http://www.google.com/search"));
QUrlQuery urlQuery;
urlQuery.addQueryItem(QLatin1String("q"), searchText);
urlQuery.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8"));
urlQuery.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8"));
urlQuery.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser"));
url.setQuery(urlQuery);
emit search(url);
}
示例11: QWidget
WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow, bool isViewerWebInstance)
: QWidget(parent)
, mWebToolBar(0)
, mSearchToolBar(0)
, mTabWidget(new WBTabWidget(this))
, mSearchAction(0)
, mUniboardMainWindow(uniboardMainWindow)
{
QWebSettings *defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
setupMenu();
if(!isViewerWebInstance)
setupToolBar();
else{
setupToolBarForTutorial();
}
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
layout->addWidget(mTabWidget);
this->setLayout(layout);
connect(mTabWidget, SIGNAL(loadPage(const QString &)), this, SLOT(loadPage(const QString &)));
connect(mTabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &)));
if (!isViewerWebInstance) {
connect(mTabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
}
示例12: setWindowTitle
void MainWindow::updateWindowTitle(const QString &title)
{
QWebSettings *settings = QWebSettings::globalSettings();
if (title.isEmpty())
{
if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
setWindowTitle(i18nc("Window title when private browsing is activated", "rekonq (Private Browsing)"));
}
else
{
setWindowTitle("rekonq");
}
}
else
{
if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq (Private Browsing)", title));
}
else
{
setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq", title));
}
}
}
示例13: eventFilter
bool ZoomEventFilter::eventFilter (QObject *viewObj, QEvent *someEvent)
{
if (someEvent->type () != QEvent::Wheel)
return false;
QWheelEvent *e = static_cast<QWheelEvent*> (someEvent);
if (!(e->modifiers () & Qt::ControlModifier))
return false;
int degrees = e->delta () / 8;
int steps = static_cast<qreal> (degrees) / 15;
QWebView *view = qobject_cast<QWebView*> (viewObj);
if (e->modifiers () & Qt::ShiftModifier)
{
auto multiplier = view->textSizeMultiplier ();
multiplier += steps * 0.1;
view->setTextSizeMultiplier (multiplier);
}
else
{
QWebSettings *settings = view->settings ();
settings->setFontSize (QWebSettings::DefaultFontSize,
std::max (6, settings->fontSize (QWebSettings::DefaultFontSize) + steps));
auto frame = view->page ()->mainFrame ();
frame->evaluateJavaScript ("setTimeout(ScrollToBottom,0);");
}
return true;
}
示例14: load
void QHFWebView::load(const QUrl &url)
{
QWebView::load(url);
QWebSettings *sets = this->page()->settings();
sets->setAttribute(QWebSettings::JavascriptEnabled,true);
sets->setAttribute(QWebSettings::LocalContentCanAccessFileUrls,true);
connect(page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(registerObject()));
}
示例15: strComposedStyle
void MyWebView::SetHighlightStyleClass(QString strClassName, QString &strTmpStyle)
{
QByteArray strComposedStyle("." + strClassName.toUtf8() + " { " + strTmpStyle.toUtf8() + " }");
QWebSettings *settings = QWebSettings::globalSettings();
settings->setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64," + strComposedStyle.toBase64()));
}