本文整理汇总了C++中QWebSettings::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings::setAttribute方法的具体用法?C++ QWebSettings::setAttribute怎么用?C++ QWebSettings::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebSettings
的用法示例。
在下文中一共展示了QWebSettings::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSettings
void BrowserApplication::loadSettings()
{
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
QWebSettings *defaultSettings = QWebSettings::globalSettings();
QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
QFont standardFont = QFont(standardFontFamily, standardFontSize);
standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
int minimumFontSize = settings.value(QLatin1String("minimumFontSize"),
defaultSettings->fontSize(QWebSettings::MinimumFontSize)).toInt();
defaultSettings->setFontSize(QWebSettings::MinimumFontSize, minimumFontSize);
QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, !(settings.value(QLatin1String("blockPopupWindows"), true).toBool()));
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
defaultSettings->setAttribute(QWebSettings::AutoLoadImages, settings.value(QLatin1String("enableImages"), true).toBool());
defaultSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, settings.value(QLatin1String("enableInspector"), false).toBool());
QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl();
defaultSettings->setUserStyleSheetUrl(url);
settings.endGroup();
}
示例2: 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();
}
示例3: settings
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: 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)));
}
示例5: 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 *)));
}
示例6: createWidget
WebWidget* QtWebKitWebBackend::createWidget(bool isPrivate, ContentsWidget *parent)
{
if (!m_isInitialized)
{
m_isInitialized = true;
QWebHistoryInterface::setDefaultInterface(new QtWebKitHistoryInterface(this));
QWebSettings *globalSettings = QWebSettings::globalSettings();
globalSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
globalSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
const QString cachePath = SessionsManager::getCachePath();
if (!cachePath.isEmpty())
{
QDir().mkpath(cachePath);
globalSettings->setIconDatabasePath(cachePath);
globalSettings->setLocalStoragePath(cachePath + QLatin1String("/localStorage/"));
globalSettings->setOfflineStoragePath(cachePath + QLatin1String("/offlineStorage/"));
globalSettings->setOfflineWebApplicationCachePath(cachePath + QLatin1String("/offlineWebApplicationCache/"));
}
QWebSettings::setMaximumPagesInCache(SettingsManager::getValue(QLatin1String("Cache/PagesInMemoryLimit")).toInt());
optionChanged(QLatin1String("Browser/"));
connect(SettingsManager::getInstance(), SIGNAL(valueChanged(QString,QVariant)), this, SLOT(optionChanged(QString)));
}
return new QtWebKitWebWidget(isPrivate, this, NULL, parent);
}
示例7: 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);
}
示例8: 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()));
}
示例9: pal
BrowserWidget::BrowserWidget(QWidget *parent, QSettings *settings, QObject *jsProxy):
QGraphicsView(parent),
scene(0),
jsProxy(jsProxy),
zoomStepFactor (settings->value("browser/zoom_step_factor").toFloat()),
homePageUrl (settings->value("browser/home_page_url").toString()),
errorPageUrl (settings->value("browser/error_url").toString()),
unsupportedPageUrl (settings->value("browser/unsupported_url").toString()),
pagesInFastHistory (settings->value("browser/pages_in_fast_history").toInt()),
freezeForMsecsWhenZooming (settings->value("browser/freeze_time_when_zoom_ms").toInt()),
freezeForMsecsWhenDragging (settings->value("browser/freeze_time_when_drag_ms").toInt()),
maxDragDistanceToEmitClick (settings->value("browser/click_if_drag_at_most_px").toInt()),
dragDistance(maxDragDistanceToEmitClick)
{
webView = new QGraphicsWebView();
webPage = new BrowserWebPage();
webView->setPage(webPage);
newScene();
// visual settings
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setFrameShape(QFrame::NoFrame);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
webView->setResizesToContents(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QPalette pal(palette());
pal.setColor(QPalette::Base, Qt::white);
setPalette(pal);
// web settings
QWebSettings *globalSettings = QWebSettings::globalSettings();
globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
globalSettings->setAttribute(QWebSettings::TiledBackingStoreEnabled, true);
globalSettings->setMaximumPagesInCache(pagesInFastHistory);
webView->page()->history()->setMaximumItemCount(pagesInFastHistory);
webView->page()->setForwardUnsupportedContent(true);
// connects
connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanging(QUrl)));
connect(webView, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(newScene()));
connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
connect(webView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
this, SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))
);
connect(&unfreezeTimer, SIGNAL(timeout()), this, SLOT(unfreezeTiles()));
unfreezeTimer.setSingleShot(true);
connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptBinding()));
addJavaScriptBinding();
}
示例10: icon
QtMainWindow::QtMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::QtMainWindow),
webInspectorWindow(new QtWebInspector()),
cb(NULL),
cur_tbrp(0),
m_alertDialog(0),
m_LogicalDpiX(0),
m_LogicalDpiY(0),
firstShow(true)
//TODO: m_SyncStatusDlg
{
#ifdef OS_WINDOWS_DESKTOP
QPixmap icon(":/images/rho.png");
QApplication::setWindowIcon(icon);
#endif
ui->setupUi(this);
QWebSettings* qs = QWebSettings::globalSettings(); //this->ui->webView->settings();
qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
qs->setAttribute(QWebSettings::LocalStorageEnabled, true);
qs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
qs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
qs->setOfflineStorageDefaultQuota(1024*1024*1024);
rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR;
qs->setOfflineWebApplicationCachePath(rs_dir.c_str());
qs->setLocalStoragePath(rs_dir.c_str());
qs->setOfflineStoragePath(rs_dir.c_str());
this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024);
this->main_webView = this->ui->webView;
this->main_webInspector = webInspectorWindow->webInspector();
this->cur_webInspector = this->main_webInspector;
this->move(0,0);
this->ui->toolBar->hide();
this->ui->toolBarRight->hide();
// connecting WebInspector
main_webInspector->setPage(ui->webView->page());
#ifdef OS_SYMBIAN
QWebViewKineticScroller *newScroller = new QWebViewKineticScroller();
newScroller->setWidget(this->ui->webView);
QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView);
#endif
#if defined(RHODES_EMULATOR)
webInspectorWindow->show();
#endif
}
示例11: postInitialize
void Manitou::postInitialize()
{
// load WebKit settings
QSettings settings;
QWebSettings *globalSettings = QWebSettings::globalSettings();
settings.beginGroup("WebKit");
globalSettings->setAttribute(QWebSettings::AutoLoadImages, settings.value("AutoLoadImages", true).toBool());
globalSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, settings.value("DevelopersExtras", true).toBool());
globalSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value("Plugins", true).toBool());
globalSettings->setAttribute(QWebSettings::LocalStorageEnabled, settings.value("LocalStorage", true).toBool());
globalSettings->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, settings.value("LocalDatabase", true).toBool());
settings.endGroup();
}
示例12: QWebPage
WebPage::WebPage(QObject* parent, DumpRenderTree* drt)
: QWebPage(parent)
, m_webInspector(0)
, m_drt(drt)
{
QWebSettings* globalSettings = QWebSettings::globalSettings();
globalSettings->setFontSize(QWebSettings::MinimumFontSize, 0);
globalSettings->setFontSize(QWebSettings::MinimumLogicalFontSize, 5);
globalSettings->setFontSize(QWebSettings::DefaultFontSize, 16);
globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13);
globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false);
connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
this, SLOT(setViewGeometry(const QRect & )));
setNetworkAccessManager(m_drt->networkAccessManager());
setPluginFactory(new TestPlugin(this));
connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(requestPermission(QWebFrame*, QWebPage::Feature)));
connect(this, SIGNAL(featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature)), this, SLOT(cancelPermission(QWebFrame*, QWebPage::Feature)));
}
示例13: QMainWindow
WebViewWindow::WebViewWindow(QWidget *parent) :
QMainWindow(parent)
{
QAction* reloadAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_BrowserReload), tr("Reload"), this);
reloadAction->setShortcut(QKeySequence(QKeySequence::Refresh));
QToolBar* toolBar = new QToolBar(tr("ToolBar"), this);
mAddressBar = new QLineEdit(toolBar);
mAddressBar->setReadOnly(true);
toolBar->addWidget(mAddressBar);
toolBar->addAction(reloadAction);
toolBar->setMovable(false);
toolBar->hide();
toolBar->installEventFilter(this);
mToolBar = toolBar;
addToolBar(toolBar);
QMenuBar* menuBar = this->menuBar();
QMenu* fileMenu = menuBar->addMenu(tr("&File"));
fileMenu->addAction(reloadAction);
QAction* quitAction = fileMenu->addAction(QIcon(":/media/application_exit.png"), tr("Quit"));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
QMenu* viewMenu = menuBar->addMenu(tr("&View"));
viewMenu->addAction(toolBar->toggleViewAction());
QMenu* debugMenu = menuBar->addMenu(tr("&Debug"));
QAction* inspectAction = debugMenu->addAction(tr("Inspect"));
connect(inspectAction, SIGNAL(triggered()), this, SLOT(showWebInspector()));
mWebView = new QWebView(this);
mWebInspector = 0;
QWebSettings* webSettings = mWebView->settings();
webSettings->setAttribute(QWebSettings::LocalStorageEnabled, true);
webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
QWidget* centralWidget = new QWidget(this);
QVBoxLayout* layout = new QVBoxLayout(centralWidget);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(mWebView);
layout->setAlignment(mWebView, Qt::AlignCenter);
setCentralWidget(centralWidget);
setWindowModality(Qt::WindowModal);
connect(reloadAction, SIGNAL(triggered()), mWebView, SLOT(reload()));
loadWebInspector();
}
示例14: QObject
LinkFetcher::LinkFetcher(const QString &site_,
const QString &scriptOrScriptName_, QObject *parent)
: QObject(parent), site(site_),
scriptOrScriptName(scriptOrScriptName_)
{
QWebSettings *webSettings = page.settings();
webSettings->setAttribute(QWebSettings::AutoLoadImages, false);
webSettings->setAttribute(QWebSettings::PluginsEnabled, false);
webSettings->setAttribute(QWebSettings::JavaEnabled, false);
webSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
webSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled,
true);
connect(page.mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
this, SLOT(injectJavaScriptIntoWindowObject()));
connect(&page, SIGNAL(loadFinished(bool)),
this, SLOT(fetchLinks(bool)));
}
示例15: QObject
WebCapture::WebCapture(QObject *parent)
: QObject(parent), zoom_(100)
{
connect(&page_, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool)));
connect(&page_, SIGNAL(loadProgress(int)), this, SLOT(showProgress(int)));
QWebSettings *settings = page_.settings();
settings->setAttribute(QWebSettings::AutoLoadImages, true);
settings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
settings->setAttribute(QWebSettings::JavascriptEnabled, true);
settings->setAttribute(QWebSettings::PluginsEnabled, false);
settings->setAttribute(QWebSettings::JavascriptCanOpenWindows, false);
settings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, false);
settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
settings->setAttribute(QWebSettings::ZoomTextOnly, false);
settings->setAttribute(QWebSettings::PrintElementBackgrounds, true);
}