
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQWebSettings class provides an object to store the settings used byQWebPage andQWebFrame.More...
| Header: | #include <QWebSettings> |
| Since: | Qt 4.4 |
| enum | FontFamily { StandardFont, FixedFont, SerifFont, SansSerifFont, CursiveFont, FantasyFont } |
| enum | FontSize { MinimumFontSize, MinimumLogicalFontSize, DefaultFontSize, DefaultFixedFontSize } |
| enum | WebAttribute { AutoLoadImages, DnsPrefetchEnabled, JavascriptEnabled, JavaEnabled, ..., SiteSpecificQuirksEnabled } |
| enum | WebGraphic { MissingImageGraphic, MissingPluginGraphic, DefaultFrameIconGraphic, TextAreaSizeGripCornerGraphic, ..., SearchCancelButtonPressedGraphic } |
| QString | defaultTextEncoding() const |
| QString | fontFamily(FontFamily which) const |
| int | fontSize(FontSize type) const |
| QString | localStoragePath() const |
| void | resetAttribute(WebAttribute attribute) |
| void | resetFontFamily(FontFamily which) |
| void | resetFontSize(FontSize type) |
| void | setAttribute(WebAttribute attribute, bool on) |
| void | setDefaultTextEncoding(const QString & encoding) |
| void | setFontFamily(FontFamily which, const QString & family) |
| void | setFontSize(FontSize type, int size) |
| void | setLocalStoragePath(const QString & path) |
| void | setUserStyleSheetUrl(const QUrl & location) |
| bool | testAttribute(WebAttribute attribute) const |
| QUrl | userStyleSheetUrl() const |
| void | clearIconDatabase() |
| void | clearMemoryCaches() |
| void | enablePersistentStorage(const QString & path = QString()) |
| QWebSettings * | globalSettings() |
| QString | iconDatabasePath() |
| QIcon | iconForUrl(const QUrl & url) |
| int | maximumPagesInCache() |
| qint64 | offlineStorageDefaultQuota() |
| QString | offlineStoragePath() |
| QString | offlineWebApplicationCachePath() |
| qint64 | offlineWebApplicationCacheQuota() |
| void | setIconDatabasePath(const QString & path) |
| void | setMaximumPagesInCache(int pages) |
| void | setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity) |
| void | setOfflineStorageDefaultQuota(qint64 maximumSize) |
| void | setOfflineStoragePath(const QString & path) |
| void | setOfflineWebApplicationCachePath(const QString & path) |
| void | setOfflineWebApplicationCacheQuota(qint64 maximumSize) |
| void | setWebGraphic(WebGraphic type, const QPixmap & graphic) |
| QPixmap | webGraphic(WebGraphic type) |
TheQWebSettings class provides an object to store the settings used byQWebPage andQWebFrame.
EachQWebPage object has its ownQWebSettings object, which configures the settings for that page. If a setting is not configured, then it is looked up in the global settings object, which can be accessed usingglobalSettings().
QWebSettings allows configuration of browser properties, such as font sizes and families, the location of a custom style sheet, and generic attributes like JavaScript and plugins. Individual attributes are set using thesetAttribute() function. TheWebAttribute enum further describes each attribute.
QWebSettings also configures global properties such as the web page memory cache, icon database, local database storage and offline applications storage.
Support for browser plugins can enabled by setting thePluginsEnabled attribute. For many applications, this attribute is enabled for all pages by setting it on theglobal settings object.QtWebKit will always ignore this setting when processing Qt plugins. The decision to allow a Qt plugin is made by the client in its reimplementation ofQWebPage::createPlugin().
WebKit provides support for features specified inHTML 5 that improve the performance and capabilities of Web applications. These include client-side (offline) storage and the use of a Web application cache.
Client-side (offline) storage is an improvement over the use of cookies to store persistent data in Web applications. Applications can configure and enable the use of an offline storage database by calling thesetOfflineStoragePath() with an appropriate file path, and can limit the quota for each application by callingsetOfflineStorageDefaultQuota().
See alsoQWebPage::settings(),QWebView::settings(), andWeb Browser.
This enum describes the generic font families defined by CSS 2. For more information see theCSS standard.
| Constant | Value |
|---|---|
QWebSettings::StandardFont | 0 |
QWebSettings::FixedFont | 1 |
QWebSettings::SerifFont | 2 |
QWebSettings::SansSerifFont | 3 |
QWebSettings::CursiveFont | 4 |
QWebSettings::FantasyFont | 5 |
This enum describes the font sizes configurable throughQWebSettings.
| Constant | Value | Description |
|---|---|---|
QWebSettings::MinimumFontSize | 0 | The hard minimum font size. |
QWebSettings::MinimumLogicalFontSize | 1 | The minimum logical font size that is applied when zooming out withQWebFrame::setTextSizeMultiplier(). |
QWebSettings::DefaultFontSize | 2 | The default font size for regular text. |
QWebSettings::DefaultFixedFontSize | 3 | The default font size for fixed-pitch text. |
This enum describes various attributes that are configurable throughQWebSettings.
| Constant | Value | Description |
|---|---|---|
QWebSettings::AutoLoadImages | 0 | Specifies whether images are automatically loaded in web pages. This is enabled by default. |
QWebSettings::DnsPrefetchEnabled | ? | Specifies whether QtWebkit will try to pre-fetch DNS entries to speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. This is disabled by default. |
QWebSettings::JavascriptEnabled | 1 | Enables or disables the running of JavaScript programs. This is enabled by default |
QWebSettings::JavaEnabled | 2 | Enables or disables Java applets. Currently Java applets are not supported. |
QWebSettings::PluginsEnabled | 3 | Enables or disables plugins in Web pages (e.g. using NPAPI). Qt plugins with a mimetype such as "application/x-qt-plugin" are not affected by this setting. This is disabled by default. |
QWebSettings::PrivateBrowsingEnabled | 4 | Private browsing preventsWebKit from recording visited pages in the history and storing web page icons. This is disabled by default. |
QWebSettings::JavascriptCanOpenWindows | 5 | Specifies whether JavaScript programs can open new windows. This is disabled by default. |
QWebSettings::JavascriptCanCloseWindows | ? | Specifies whether JavaScript programs can close windows. This is disabled by default. |
QWebSettings::JavascriptCanAccessClipboard | 6 | Specifies whether JavaScript programs can read or write to the clipboard. This is disabled by default. |
QWebSettings::DeveloperExtrasEnabled | 7 | Enables extra tools for Web developers. Currently this enables the "Inspect" element in the context menu as well as the use ofQWebInspector which controls the web inspector for web site debugging. This is disabled by default. |
QWebSettings::SpatialNavigationEnabled | ? | Enables or disables the Spatial Navigation feature, which consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be trying to reach towards the right and which element he probably wants. This is disabled by default. |
QWebSettings::LinksIncludedInFocusChain | 8 | Specifies whether hyperlinks should be included in the keyboard focus chain. This is enabled by default. |
QWebSettings::ZoomTextOnly | 9 | Specifies whether the zoom factor on a frame applies only to the text or to all content. This is disabled by default. |
QWebSettings::PrintElementBackgrounds | 10 | Specifies whether the background color and images are also drawn when the page is printed. This is enabled by default. |
QWebSettings::OfflineStorageDatabaseEnabled | 11 | Specifies whether support for the HTML 5 offline storage feature is enabled or not. This is disabled by default. |
QWebSettings::OfflineWebApplicationCacheEnabled | 12 | Specifies whether support for the HTML 5 web application cache feature is enabled or not. This is disabled by default. |
QWebSettings::LocalStorageEnabled | 13 | Specifies whether support for the HTML 5 local storage feature is enabled or not. This is disabled by default. (This value was introduced in 4.6.) |
QWebSettings::LocalStorageDatabaseEnabled | LocalStorageEnabled | This enum value is deprecated. Use QWebSettings::LocalStorageEnabled instead. |
QWebSettings::LocalContentCanAccessRemoteUrls | ? | Specifies whether locally loaded documents are allowed to access remote urls. This is disabled by default. For more information about security origins and local vs. remote content seeQWebSecurityOrigin. (This value was introduced in 4.6.) |
QWebSettings::LocalContentCanAccessFileUrls | ? | Specifies whether locally loaded documents are allowed to access other local urls. This is enabled by default. For more information about security origins and local vs. remote content seeQWebSecurityOrigin. |
QWebSettings::XSSAuditingEnabled | ? | Specifies whether load requests should be monitored for cross-site scripting attempts. Suspicious scripts will be blocked and reported in the inspector's JavaScript console. Enabling this feature might have an impact on performance and it is disabled by default. |
QWebSettings::AcceleratedCompositingEnabled | ? | This feature, when used in conjunction withQGraphicsWebView, accelerates animations of web content. CSS animations of the transform and opacity properties will be rendered by composing the cached content of the animated elements. This is enabled by default. |
QWebSettings::TiledBackingStoreEnabled | ? | This setting enables the tiled backing store feature for aQGraphicsWebView. With the tiled backing store enabled, the web page contents in and around the current visible area is speculatively cached to bitmap tiles. The tiles are automatically kept in sync with the web page as it changes. Enabling tiling can significantly speed up painting heavy operations like scrolling. Enabling the feature increases memory consumption. It does not work well with contents using CSS fixed positioning (see alsoresizesToContents property).tiledBackingStoreFrozen property allows application to temporarily freeze the contents of the backing store. This is disabled by default. |
QWebSettings::FrameFlatteningEnabled | ? | With this setting each subframe is expanded to its contents. On touch devices, it is desired to not have any scrollable sub parts of the page as it results in a confusing user experience, with scrolling sometimes scrolling sub parts and at other times scrolling the page itself. For this reason iframes and framesets are barely usable on touch devices. This will flatten all the frames to become one scrollable page. This is disabled by default. |
QWebSettings::SiteSpecificQuirksEnabled | ? | This setting enablesWebKit's workaround for broken sites. It is enabled by default. |
This enums describes the standard graphical elements used in webpages.
| Constant | Value | Description |
|---|---|---|
QWebSettings::MissingImageGraphic | 0 | The replacement graphic shown when an image could not be loaded. |
QWebSettings::MissingPluginGraphic | 1 | The replacement graphic shown when a plugin could not be loaded. |
QWebSettings::DefaultFrameIconGraphic | 2 | The default icon forQWebFrame::icon(). |
QWebSettings::TextAreaSizeGripCornerGraphic | 3 | The graphic shown for the size grip of text areas. |
QWebSettings::DeleteButtonGraphic | 4 | The graphic shown for theWebKit-Editing-Delete-Button in Deletion UI. |
QWebSettings::InputSpeechButtonGraphic | 5 | The graphic shown in input fields that support speech recognition. |
QWebSettings::SearchCancelButtonGraphic | 6 | The graphic shown for clearing the text in a search field. |
QWebSettings::SearchCancelButtonPressedGraphic | 7 | The graphic shown when SearchCancelButtonGraphic is pressed. |
[static]void QWebSettings::clearIconDatabase()Clears the icon database.
[static]void QWebSettings::clearMemoryCaches()Frees up as much memory as possible by cleaning all memory caches such as page, object and font cache.
This function was introduced in Qt 4.6.
Returns the default text encoding.
This function was introduced in Qt 4.6.
See alsosetDefaultTextEncoding().
[static]void QWebSettings::enablePersistentStorage(constQString & path = QString())EnablesWebKit data persistence and sets the path topath. Ifpath is empty, the user-specific data location specified byDataLocation will be used instead.
This method will simultaneously set and enable theiconDatabasePath(),localStoragePath(),offlineStoragePath() andofflineWebApplicationCachePath().
This function was introduced in Qt 4.6.
See alsolocalStoragePath().
Returns the actual font family for the specified generic font family,which.
See alsosetFontFamily().
Returns the default font size fortype.
See alsosetFontSize().
[static]QWebSettings * QWebSettings::globalSettings()Returns the global settings object.
Any setting changed on the default object is automatically applied to allQWebPage instances where the particular setting is not overriden already.
[static]QString QWebSettings::iconDatabasePath()Returns the path of the icon database or an empty string if the icon database is disabled.
See alsosetIconDatabasePath() andclearIconDatabase().
[static]QIcon QWebSettings::iconForUrl(constQUrl & url)Returns the web site's icon forurl.
If the web site does not specify an iconOR if the icon is not in the database, a nullQIcon is returned.
Note:The returned icon's size is arbitrary.
See alsosetIconDatabasePath().
Returns the path for HTML5 local storage.
This function was introduced in Qt 4.6.
See alsosetLocalStoragePath().
[static]int QWebSettings::maximumPagesInCache()Returns the maximum number of web pages that are kept in the memory cache.
See alsosetMaximumPagesInCache().
[static]qint64 QWebSettings::offlineStorageDefaultQuota()Returns the value of the default quota for new offline storage databases.
This function was introduced in Qt 4.5.
See alsosetOfflineStorageDefaultQuota().
[static]QString QWebSettings::offlineStoragePath()Returns the path of the HTML5 client-side database storage or an empty string if the feature is disabled.
This function was introduced in Qt 4.5.
See alsosetOfflineStoragePath().
[static]QString QWebSettings::offlineWebApplicationCachePath()Returns the path of the HTML5 offline web application cache storage or an empty string if the feature is disabled.
This function was introduced in Qt 4.6.
See alsosetOfflineWebApplicationCachePath().
[static]qint64 QWebSettings::offlineWebApplicationCacheQuota()Returns the value of the quota for the offline web application cache.
This function was introduced in Qt 4.6.
See alsosetOfflineWebApplicationCacheQuota().
Resets the setting ofattribute to the value specified in the globalQWebSettings instance.
This function has no effect on the globalQWebSettings instance.
See alsoglobalSettings().
Resets the actual font family specified bywhich to the one set in the globalQWebSettings instance.
This function has no effect on the globalQWebSettings instance.
Resets the font size fortype to the size specified in the global settings object.
This function has no effect on the globalQWebSettings instance.
Enables or disables the specifiedattribute feature depending on the value ofon.
Specifies the default text encoding system.
Theencoding, must be a string describing an encoding such as "utf-8", "iso-8859-1", etc. If left empty a default value will be used. For a more extensive list of encoding names seeQTextCodec
This function was introduced in Qt 4.6.
See alsodefaultTextEncoding().
Sets the actual font family tofamily for the specified generic family,which.
See alsofontFamily().
Sets the font size fortype tosize.
See alsofontSize().
[static]void QWebSettings::setIconDatabasePath(constQString & path)Sets the path of the icon database topath. The icon database is used to store "favicons" associated with web sites.
path must point to an existing directory.
Setting an empty path disables the icon database.
See alsoiconDatabasePath() andclearIconDatabase().
Sets the path for HTML5 local storage topath.
For more information on HTML5 local storage see theWeb Storage standard.
Support for local storage can enabled by setting theLocalStorageEnabled attribute.
This function was introduced in Qt 4.6.
See alsolocalStoragePath().
[static]void QWebSettings::setMaximumPagesInCache(int pages)Sets the maximum number of pages to hold in the memory page cache topages.
The Page Cache allows for a nicer user experience when navigating forth or back to pages in the forward/back history, by pausing and resuming up topages.
For more information about the feature, please refer to:
http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
See alsomaximumPagesInCache().
[static]void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity,int cacheMaxDead,int totalCapacity)Specifies the capacities for the memory cache for dead objects such as stylesheets or scripts.
ThecacheMinDeadCapacity specifies theminimum number of bytes that dead objects should consume when the cache is under pressure.
cacheMaxDead is themaximum number of bytes that dead objects should consume when the cache isnot under pressure.
totalCapacity specifies themaximum number of bytes that the cache should consumeoverall.
The cache is enabled by default. Calling setObjectCacheCapacities(0, 0, 0) will disable the cache. Calling it with one non-zero enables it again.
[static]void QWebSettings::setOfflineStorageDefaultQuota(qint64 maximumSize)Sets the value of the default quota for new offline storage databases tomaximumSize.
This function was introduced in Qt 4.5.
See alsoofflineStorageDefaultQuota().
[static]void QWebSettings::setOfflineStoragePath(constQString & path)Setspath as the save location for HTML5 client-side database storage data.
path must point to an existing directory.
Setting an empty path disables the feature.
Support for client-side databases can enabled by setting theOfflineStorageDatabaseEnabled attribute.
This function was introduced in Qt 4.5.
See alsoofflineStoragePath().
[static]void QWebSettings::setOfflineWebApplicationCachePath(constQString & path)Sets the path for HTML5 offline web application cache storage topath.
An application cache acts like an HTTP cache in some sense. For documents that use the application cache via JavaScript, the loader engine will first ask the application cache for the contents, before hitting the network.
The feature is described in details at: http://dev.w3.org/html5/spec/Overview.html#appcache
path must point to an existing directory.
Setting an empty path disables the feature.
Support for offline web application cache storage can enabled by setting theOfflineWebApplicationCacheEnabled attribute.
This function was introduced in Qt 4.6.
See alsoofflineWebApplicationCachePath().
[static]void QWebSettings::setOfflineWebApplicationCacheQuota(qint64 maximumSize)Sets the value of the quota for the offline web application cache tomaximumSize.
This function was introduced in Qt 4.6.
See alsoofflineWebApplicationCacheQuota().
Specifies the location of a user stylesheet to load with every web page.
Thelocation must be either a path on the local filesystem, or a data URL with UTF-8 and Base64 encoded data, such as:
"data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow=="
Note:If the base64 data is not valid, the style will not be applied.
See alsouserStyleSheetUrl().
[static]void QWebSettings::setWebGraphic(WebGraphic type, constQPixmap & graphic)Setsgraphic to be drawn whenQtWebKit needs to draw an image of the giventype.
For example, when an image cannot be loaded, the pixmap specified byMissingImageGraphic is drawn instead.
See alsowebGraphic().
Returns true ifattribute is enabled; otherwise returns false.
Returns the location of the user stylesheet.
See alsosetUserStyleSheetUrl().
[static]QPixmap QWebSettings::webGraphic(WebGraphic type)Returns a previously set pixmap used to draw replacement graphics of the specifiedtype.
See alsosetWebGraphic().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.