|  | Home · All Classes · Modules

# QWebSettings Class Reference
[QtWebKit module]

The QWebSettings class provides an object to store the settings used by QWebPage and QWebFrame. More...

### Types

- enum FontFamily { StandardFont, FixedFont, SerifFont, SansSerifFont, CursiveFont, FantasyFont }
- enum FontSize { MinimumFontSize, MinimumLogicalFontSize, DefaultFontSize, DefaultFixedFontSize }
- enum WebAttribute { AutoLoadImages, JavascriptEnabled, JavaEnabled, PluginsEnabled, ..., LocalStorageDatabaseEnabled }
- enum WebGraphic { MissingImageGraphic, MissingPluginGraphic, DefaultFrameIconGraphic, TextAreaSizeGripCornerGraphic }

### Methods

- QString fontFamily (self, FontFamily which)
- int fontSize (self, FontSize type)
- resetAttribute (self, WebAttribute attr)
- resetFontFamily (self, FontFamily which)
- resetFontSize (self, FontSize type)
- setAttribute (self, WebAttribute attr, bool on)
- setFontFamily (self, FontFamily which, QString family)
- setFontSize (self, FontSize type, int size)
- setUserStyleSheetUrl (self, QUrl location)
- bool testAttribute (self, WebAttribute attr)
- QUrl userStyleSheetUrl (self)

### Static Methods

- clearIconDatabase ()
- QWebSettings globalSettings ()
- QString iconDatabasePath ()
- QIcon iconForUrl (QUrl url)
- int maximumPagesInCache ()
- long offlineStorageDefaultQuota ()
- QString offlineStoragePath ()
- setIconDatabasePath (QString location)
- setMaximumPagesInCache (int pages)
- setObjectCacheCapacities (int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
- setOfflineStorageDefaultQuota (long maximumSize)
- setOfflineStoragePath (QString path)
- setWebGraphic (WebGraphic type, QPixmap graphic)
- QPixmap webGraphic (WebGraphic type)

## Detailed Description

The QWebSettings class provides an object to store the settings used by QWebPage and QWebFrame.

Each QWebPage object has its own QWebSettings 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 using QWebSettings.globalSettings().

QWebSettings allows configuring font properties such as font size and font family, the location of a custom stylesheet, and generic attributes like java script, plugins, etc. The WebAttribute enum further describes this.

QWebSettings also configures global properties such as the web page memory cache and the web page icon database, local database storage and offline applications storage.

### Web Application Support

WebKit provides support for features specified in HTML 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 the setOfflineStoragePath() with an appropriate file path, and can limit the quota for each application by calling setOfflineStorageDefaultQuota().

See also QWebPage.settings(), QWebView.settings(), and Browser.

## Type Documentation

### QWebSettings.FontFamily

This enum describes the generic font families defined by CSS 2. For more information see the CSS standard.

Constant | Value
--- | ---
`QWebSettings.StandardFont` | `0`
`QWebSettings.FixedFont` | `1`
`QWebSettings.SerifFont` | `2`
`QWebSettings.SansSerifFont` | `3`
`QWebSettings.CursiveFont` | `4`
`QWebSettings.FantasyFont` | `5`

### QWebSettings.FontSize

This enum describes the font sizes configurable through QWebSettings.

Constant | Value | Description
--- | --- | ---
`QWebSettings.MinimumFontSize` | `0` | The hard minimum font size.
`QWebSettings.MinimumLogicalFontSize` | `1` | The minimum logical font size that is applied after zooming with QWebFrame's textSizeMultiplier().
`QWebSettings.DefaultFontSize` | `2` | The default font size for regular text.
`QWebSettings.DefaultFixedFontSize` | `3` | The default font size for fixed-pitch text.

### QWebSettings.WebAttribute

This enum describes various attributes that are configurable through QWebSettings.

Constant | Value | Description
--- | --- | ---
`QWebSettings.AutoLoadImages` | `0` | Specifies whether images are automatically loaded in web pages.
`QWebSettings.JavascriptEnabled` | `1` | Enables or disables the running of JavaScript programs.
`QWebSettings.JavaEnabled` | `2` | Enables or disables Java applets. Currently Java applets are not supported.
`QWebSettings.PluginsEnabled` | `3` | Enables or disables plugins in Web pages.
`QWebSettings.PrivateBrowsingEnabled` | `4` | Private browsing prevents WebKit from recording visited pages in the history and storing web page icons.
`QWebSettings.JavascriptCanOpenWindows` | `5` | Specifies whether JavaScript programs can open new windows.
`QWebSettings.JavascriptCanAccessClipboard` | `6` | Specifies whether JavaScript programs can read or write to the clipboard.
`QWebSettings.DeveloperExtrasEnabled` | `7` | Enables extra tools for Web developers. Currently this enables the "Inspect" element in the context menu, which shows the WebKit WebInspector for web site debugging.
`QWebSettings.LinksIncludedInFocusChain` | `8` | Specifies whether hyperlinks should be included in the keyboard focus chain.
`QWebSettings.ZoomTextOnly` | `9` | Specifies whether the zoom factor on a frame applies to only the text or all content.
`QWebSettings.PrintElementBackgrounds` | `10` | Specifies whether the background color and images are also drawn when the page is printed.
`QWebSettings.OfflineStorageDatabaseEnabled` | `11` | Specifies whether support for the HTML 5 offline storage feature is enabled or not.
`QWebSettings.OfflineWebApplicationCacheEnabled` | `12` | Specifies whether support for the HTML 5 web application cache feature is enabled or not.
`QWebSettings.LocalStorageDatabaseEnabled` | `13` | Specifies whether support for the HTML 5 local storage feature is enabled or not.

### QWebSettings.WebGraphic

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 for QWebFrame.icon().
`QWebSettings.TextAreaSizeGripCornerGraphic` | `3` | The graphic shown for the size grip of text areas.

## Method Documentation

### QWebSettings.clearIconDatabase ()

Clears the icon database.

### QString QWebSettings.fontFamily (self, FontFamily which)

Returns the actual font family for the specified generic font family, which.

See also setFontFamily().

### int QWebSettings.fontSize (self, FontSize type)

Returns the default font size for type.

See also setFontSize().

### QWebSettings QWebSettings.globalSettings ()

Returns the global settings object.

Any setting changed on the default object is automatically applied to all QWebPage instances where the particular setting is not overriden already.

### QString QWebSettings.iconDatabasePath ()

Returns the path of the icon database or an empty string if the icon database is disabled.

See also setIconDatabasePath() and clearIconDatabase().

### QIcon QWebSettings.iconForUrl (QUrl url)

Returns the web site's icon for url.

If the web site does not specify an icon, or the icon is not in the database, a null QIcon is returned.

Note: The returned icon's size is arbitrary.

See also setIconDatabasePath().

### int QWebSettings.maximumPagesInCache ()

Returns the maximum number of web pages that are kept in the memory cache.

See also setMaximumPagesInCache().

### long QWebSettings.offlineStorageDefaultQuota ()

Returns the value of the default quota for new offline storage databases.

This function was introduced in Qt 4.5.

See also setOfflineStorageDefaultQuota().

### QString QWebSettings.offlineStoragePath ()

Returns the path of the HTML5 offline storage or an empty string if the feature is disabled.

This function was introduced in Qt 4.5.

See also setOfflineStoragePath().

### QWebSettings.resetAttribute (self, WebAttribute attr)

Resets the setting of attribute. This function has no effect on the global QWebSettings instance.

See also globalSettings().

### QWebSettings.resetFontFamily (self, FontFamily which)

Resets the actual font family to the default font family, specified by which.

This function has no effect on the global QWebSettings instance.

### QWebSettings.resetFontSize (self, FontSize type)

Resets the font size for type to the size specified in the global settings object.

This function has no effect on the global QWebSettings instance.

### QWebSettings.setAttribute (self, WebAttribute attr, bool on)

Enables or disables the specified attribute feature depending on the value of on.

### QWebSettings.setFontFamily (self, FontFamily which, QString family)

Sets the actual font family to family for the specified generic family, which.

See also fontFamily().

### QWebSettings.setFontSize (self, FontSize type, int size)

Sets the font size for type to size.

See also fontSize().

### QWebSettings.setIconDatabasePath (QString location)

Sets the path of the icon database to path. The icon database is used to store "favicons" associated with web sites.

path must point to an existing directory where the icons are stored.

Setting an empty path disables the icon database.

See also iconDatabasePath().

### QWebSettings.setMaximumPagesInCache (int pages)

Sets the maximum number of pages to hold in the memory cache to pages.

See also maximumPagesInCache().

### QWebSettings.setObjectCacheCapacities (int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)

Specifies the capacities for the memory cache for dead objects such as stylesheets or scripts.

The cacheMinDeadCapacity specifies the minimum number of bytes that dead objects should consume when the cache is under pressure.

cacheMaxDead is the maximum number of bytes that dead objects should consume when the cache is not under pressure.

totalCapacity specifies the maximum number of bytes that the cache should consume overall.

The cache is enabled by default. Calling setObjectCacheCapacities(0, 0, 0) will disable the cache. Calling it with one non-zero enables it again.

### QWebSettings.setOfflineStorageDefaultQuota (long maximumSize)

Sets the value of the default quota for new offline storage databases to maximumSize.

This function was introduced in Qt 4.5.

See also offlineStorageDefaultQuota().

### QWebSettings.setOfflineStoragePath (QString path)

Sets the path for HTML5 offline storage to path.

path must point to an existing directory where the databases are stored.

Setting an empty path disables the feature.

This function was introduced in Qt 4.5.

See also offlineStoragePath().

### QWebSettings.setUserStyleSheetUrl (self, QUrl location)

Specifies the location of a user stylesheet to load with every web page.

The location can be a URL or a path on the local filesystem.

See also userStyleSheetUrl().

### QWebSettings.setWebGraphic (WebGraphic type, QPixmap graphic)

Sets graphic to be drawn when QtWebKit needs to draw an image of the given type.

For example, when an image cannot be loaded the pixmap specified by MissingImageGraphic is drawn instead.

See also webGraphic().

### bool QWebSettings.testAttribute (self, WebAttribute attr)

Returns true if attribute is enabled; otherwise returns false.

### QUrl QWebSettings.userStyleSheetUrl (self)

Returns the location of the user stylesheet.

See also setUserStyleSheetUrl().

### QPixmap QWebSettings.webGraphic (WebGraphic type)

Returns a previously set pixmap used to draw replacement graphics of the specified type.

For example, when an image cannot be loaded the pixmap specified by MissingImageGraphic is drawn instead.

See also setWebGraphic().