WebSettings

#include <bb/cascades/WebSettings>

Settings for the bb::cascades::WebView control.

Each WebView instance has an associated WebSettings instance, which can be referenced by reading the WebView settings property. You should never have any reason to create an instance of this class yourself. Has to be a QObject derivative in order to be accessible from QML.

Since:

BlackBerry 10.0.0

Public Functions Index

intdefaultFontSize () const
Q_SLOT voidsetDefaultFontSize (int size)
Q_SLOT voidresetDefaultFontSize ()
booldefaultFontSizeFollowsSystemFontSize () const
Q_SLOT voidsetDefaultFontSizeFollowsSystemFontSize (bool follows)
Q_SLOT voidresetDefaultFontSizeFollowsSystemFontSize ()
boolisJavaScriptEnabled () const
Q_SLOT voidsetJavaScriptEnabled (bool enabled)
Q_SLOT voidresetJavaScriptEnabled ()
boolisImageDownloadingEnabled () const
Q_SLOT voidsetImageDownloadingEnabled (bool enabled)
Q_SLOT voidresetImageDownloadingEnabled ()
intminimumFontSize () const
Q_SLOT voidsetMinimumFontSize (int size)
Q_SLOT voidresetMinimumFontSize ()
QStringuserAgent () const
Q_SLOT voidsetUserAgent (const QString &userAgent)
QUrluserStyleSheetLocation () const
Q_SLOT voidsetUserStyleSheetLocation (const QUrl &location)
Q_SLOT voidresetUserStyleSheetLocation ()
boolisWebInspectorEnabled () const
Q_SLOT voidsetWebInspectorEnabled (bool enabled)
Q_SLOT voidresetWebInspectorEnabled ()
boolisZoomToFitEnabled () const
Q_SLOT voidsetZoomToFitEnabled (bool enabled)
Q_SLOT voidresetZoomToFitEnabled ()
boolisActiveTextEnabled () const
Q_SLOT voidsetActiveTextEnabled (bool enabled)
Q_SLOT voidresetActiveTextEnabled ()
QVariantMapviewportArguments () const
Q_SLOT voidsetViewportArguments (const QVariantMap &arguments)
Q_SLOT voidresetViewportArguments ()
QVariantbackground () const
Q_SLOT voidsetBackground (const bb::cascades::Paint &paint)
Q_SLOT voidresetBackground ()
boolisBinaryFontDownloadingEnabled () const
Q_SLOT voidsetBinaryFontDownloadingEnabled (bool enabled)
Q_SLOT voidresetBinaryFontDownloadingEnabled ()
boolareCookiesEnabled () const
Q_SLOT voidsetCookiesEnabled (bool enabled)
Q_SLOT voidresetCookiesEnabled ()
QVariantMapcustomHttpHeaders () const
Q_SLOT voidsetCustomHttpHeaders (const QVariantMap &httpHeaders)
Q_SLOT voidresetCustomHttpHeaders ()
doubledevicePixelRatio () const
Q_SLOT voidsetDevicePixelRatio (double ratio)
Q_SLOT voidresetDevicePixelRatio ()
boolisCredentialAutoFillEnabled () const
Q_SLOT voidsetCredentialAutoFillEnabled (bool enabled)
Q_SLOT voidresetCredentialAutoFillEnabled ()
boolisFormAutoFillEnabled () const
Q_SLOT voidsetFormAutoFillEnabled (bool enabled)
Q_SLOT voidresetFormAutoFillEnabled ()
QStringdefaultTextCodecName () const
Q_SLOT voidsetDefaultTextCodecName (const QString &codec)
Q_SLOT voidresetDefaultTextCodecName ()

Signals Index

voiddefaultFontSizeChanged (int newDefaultFontSize)
voiddefaultFontSizeFollowsSystemFontSizeChanged (bool newDefaultFontSizeFollowsSystemFontSize)
voidjavaScriptEnabledChanged (bool enabled)
voidimageDownloadingEnabledChanged (bool enabled)
voidminimumFontSizeChanged (int newMinimumFontSize)
voiduserAgentChanged (QString newUserAgent)
voiduserStyleSheetLocationChanged (QUrl newUserStyleSheetLocation)
voidwebInspectorEnabledChanged (bool enabled)
voidzoomToFitEnabledChanged (bool enabled)
boolactiveTextEnabledChanged (bool enabled)
voidviewportArgumentsChanged (const QVariantMap &newViewportArguments)
voidbackgroundChanged (const QVariant &newBackground)
voidbinaryFontDownloadingEnabledChanged (bool enabled)
voidcookiesEnabledChanged (bool enabled)
voidcustomHttpHeadersChanged (const QVariantMap &newCustomHttpHeaders)
voiddevicePixelRatioChanged (double newDevicePixelRatio)
voidcredentialAutoFillEnabledChanged (bool enabled)
voidformAutoFillEnabledChanged (bool enabled)
voiddefaultTextCodecNameChanged (const QString &codec)

Properties

int defaultFontSize

Specifies a default font size in CSS pixels to use when none is present in the HTML.

The default is 16.

Since:

BlackBerry 10.0.0

bool defaultFontSizeFollowsSystemFontSize

Specifies that the default font size should follow the system font size.

Any value set using the defaultFontSize property will be ignored while this setting is true.

The default is false.

Since:

BlackBerry 10.0.0

bool javaScriptEnabled

Indicates whether the execution of JavaScript should be enabled in the main frame of the webpage.

The default is true.

Since:

BlackBerry 10.0.0

bool imageDownloadingEnabled

Specifies whether images should be loaded automatically.

The default is true.

Since:

BlackBerry 10.0.0

int minimumFontSize

Specifies a minimum font size in CSS pixels.

The default is 8.

Since:

BlackBerry 10.0.0

QString userAgent

Specifies a UserAgent string to be used instead of the device default UserAgent.

The default is the same as the UserAgent employed by the BlackBerry Browser; it depends on the form factor and operating system version present on the device.

Since:

BlackBerry 10.0.0

QUrl userStyleSheetLocation

Specifies a default override CSS file location.

The default is an empty url which indicates there is no user style sheet.

Since:

BlackBerry 10.0.0

bool webInspectorEnabled

Indicates whether the execution of JavaScript should be enabled in the main frame of the webpage.

The default is false. The WebInspector is specifically for debugging and should never be enabled in released software.

Since:

BlackBerry 10.0.0

bool zoomToFitEnabled

Specifies whether the content should be zoomed out to fit the screen upon loading.

The default is true.

Since:

BlackBerry 10.0.0

bool activeTextEnabled

Specifies whether a post-processor should run over loaded content to highlight any ActiveText segments and connect them to the Invocation Framework.

This processing takes place immediately after any document load completes; it is expensive.

The default is false.

Since:

BlackBerry 10.0.0

QVariantMap viewport

This map exposes all of the arguments of the HTML Meta Viewport Tag.

It can be assigned a series of key value pairs from the following sets:

The following case-sensitive strings are accepted as keys: { "intial-scale", "minimum-scale", "maximum-scale", "width", "height", "user-scalable" }

The following case-sensitive strings are accepted for all viewport values though not all of them are necessarily useful for each property: { "auto", "desktop-width", "device-width", "device-height" }

In addition, any non-negative floating point values are also acceptable.

To set a common type of meta viewport tag that requests that the content be laid out to the screen width, and zoomed 1:1, use this:

The default is an empty map which indicates no user specified viewport meta tag should be used.

WebView {
    id: webView
    url: "http://myserver.mynetwork.net/anycontent.html"
    settings.viewport: { "width" : "device-width", "initial-scale" : 1.0 }
}
Since:

BlackBerry 10.0.0

QVariant background

Set the background color of the web page.

If you wish to enable controls behind the WebView to appear through the web page, you must set a non-opaque color.

The default is opaque white.

Since:

BlackBerry 10.0.0

bool binaryFontDownloadingEnabled

Specifies whether binary "WebFonts" should be loaded automatically.

The default is true.

Since:

BlackBerry 10.0.0

bool cookiesEnabled

Specifies whether network cookies should be enabled.

The default is true.

Since:

BlackBerry 10.0.0

QVariantMap customHttpHeaders

Specifies custom HTTP headers that will be added to every outgoing network request.

Each key value pair in the map will be converted to UTF8 strings and added to outgoing requests as "<key>: <value>".

The following code example will add a "Pragma: no-cache" header to every outgoing request:
WebView {
    url: "http://myserver.mynetwork.net/anycontent.html"
    settings.customHttpHeaders: { "Pragma": "no-cache" }
}

The default is an empty map, i.e. no custom HTTP headers.

Since:

BlackBerry 10.0.0

double devicePixelRatio

devicePixelRatio specify default scaling factor.

devicePixelRatio is the ratio between physical pixels and device-independent pixels (dips) on the device.

Increasing devicePixelRatio will zoom in the content and decreasing it will zoom out the content.

Since:

BlackBerry 10.0.0

bool credentialAutoFillEnabled

Specify whether known credentials can be automatically submitted with HTTP requests.

The default is false, setting to true can reduce the amount of times the user is prompted for credentials.

Since:

BlackBerry 10.1.0

bool formAutoFillEnabled

Specify whether known form fields can be automatically filled out on the users behalf.

The default is false, setting to true can reduce the amount of input the user needs to type.

Since:

BlackBerry 10.1.0

QString defaultTextCodecName

Set the default character encoding fallback for when no encoding information is available.

The default is ISO-8859-1.

Since:

BlackBerry 10.1.0

Public Functions

int defaultFontSize ()

Get the default font size for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setDefaultFontSize (
  • intsize)

Set the default font size for the WebView.

Parameters
size

A default font size in CSS pixels.

Since:

BlackBerry 10.0.0

Q_SLOT void resetDefaultFontSize ()

Reset the default font size to its default value of 16.

Since:

BlackBerry 10.0.0

bool defaultFontSizeFollowsSystemFontSize ()

Get whether or not the default font size follows the system font size.

Since:

BlackBerry 10.0.0

Q_SLOT void setDefaultFontSizeFollowsSystemFontSize (
  • boolfollows)

Set whether the default font size follows the system font size.

Parameters
follows

Set true to enable this feature, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetDefaultFontSizeFollowsSystemFontSize ()

Reset default font size follows system font size to its default value of false.

Since:

BlackBerry 10.0.0

bool isJavaScriptEnabled ()

Get whether or not JavaScript is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setJavaScriptEnabled (
  • boolenabled)

Set whether JavaScript will be enabled on the WebView.

Parameters
enabled

Set true to enable JavaScript, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetJavaScriptEnabled ()

Reset JavaScriptEnabled to its default value of true.

Since:

BlackBerry 10.0.0

bool isImageDownloadingEnabled ()

Get whether or not image downloading is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setImageDownloadingEnabled (
  • boolenabled)

Set whether images will be downloaded by the WebView.

Parameters
enabled

Set true to enable image downloading, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetImageDownloadingEnabled ()

Reset ImageDownloadingEnabled to its default value of true.

Since:

BlackBerry 10.0.0

int minimumFontSize ()

Get the minimum font size for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setMinimumFontSize (
  • intsize)

Set the WebView minimum font size.

Parameters
size

A minimum font size in CSS pixels.

Since:

BlackBerry 10.0.0

Q_SLOT void resetMinimumFontSize ()

Reset the minimum font size to its default value of 8.

Since:

BlackBerry 10.0.0

QString userAgent ()

Get the UserAgent used by the WebView for outgoing HTTP Requests.

Since:

BlackBerry 10.0.0

Q_SLOT void setUserAgent (

Set a UserAgent string to use instead of the default UserAgent.

Parameters
userAgent

A new user agent string to use with outgoing HTTP requests.

Since:

BlackBerry 10.0.0

QUrl userStyleSheetLocation ()

Get the UserStyleSheetLocation for the WebView.

An empty QUrl indicates no user stylesheet is in use.

Since:

BlackBerry 10.0.0

Q_SLOT void setUserStyleSheetLocation (
  • const QUrl &location)

Set a location for a default CSS file.

Parameters
location

A url to a file containing default CSS.

Since:

BlackBerry 10.0.0

Q_SLOT void resetUserStyleSheetLocation ()

Reset the user style sheet to its default value of an empty url.

Since:

BlackBerry 10.0.0

bool isWebInspectorEnabled ()

Get whether or not the WebInspector is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setWebInspectorEnabled (
  • boolenabled)

Sets the WebInspector on or off.

Parameters
enabled

Set true to enable the WebInspector, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetWebInspectorEnabled ()

Reset the web inspector to being disabled.

Since:

BlackBerry 10.0.0

bool isZoomToFitEnabled ()

Get whether or not zoom to fit after loading is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setZoomToFitEnabled (
  • boolenabled)

Sets zoom to fit behaviour for the WebView.

Parameters
enabled

Set true to enable zoom to fit on load, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetZoomToFitEnabled ()

Reset zoom to fit enabled to true.

Since:

BlackBerry 10.0.0

bool isActiveTextEnabled ()

Get whether or not active text matching after loading is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setActiveTextEnabled (
  • boolenabled)

Sets ActiveText parsing enabled.

Parameters
enabled

Set true to enable active text matching, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetActiveTextEnabled ()

Resets active text matching to false.

Since:

BlackBerry 10.0.0

QVariantMap viewportArguments ()

Get a map of user viewport arguments for the WebView.

An empty map indicates no user viewport arguments are in use.

Since:

BlackBerry 10.0.0

Q_SLOT void setViewportArguments (

Set a map of meta viewport arguments.

Parameters
arguments

A QVariantMap of viewport arguments to be used if none is specified in the html.

Since:

BlackBerry 10.0.0

Q_SLOT void resetViewportArguments ()

Resets the user viewport arguments to an empty map.

Since:

BlackBerry 10.0.0

QVariant background ()

Get the background of this WebView.

The QVariant returned wraps around a bb::cascades::Paint instance.

Since:

BlackBerry 10.0.0

Q_SLOT void setBackground (

Set a bb::cascades::Paint& background for this WebView.

Presently only ColorPaint is supported. Other Paints will be ignored. A non-opaque color can be used to allow controls behind this WebView to be visible.

The default is opaque white.

Parameters
paint

A ColorPaint to be used as a background for this WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void resetBackground ()

Resets the background to opaque white.

Since:

BlackBerry 10.0.0

bool isBinaryFontDownloadingEnabled ()

Get whether or not WebFont downloading is enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setBinaryFontDownloadingEnabled (
  • boolenabled)

Set whether or not WebFonts should be downloaded.

Parameters
enabled

Set true to enable downloading of web fonts, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetBinaryFontDownloadingEnabled ()

Resets binary font downloading to true.

Since:

BlackBerry 10.0.0

bool areCookiesEnabled ()

Get whether or not cookies are enabled for the WebView.

Since:

BlackBerry 10.0.0

Q_SLOT void setCookiesEnabled (
  • boolenabled)

Set whether or not cookies should be enabled.

Parameters
enabled

Set true to enable cookies, false to disable.

Since:

BlackBerry 10.0.0

Q_SLOT void resetCookiesEnabled ()

Resets cookies enabled to true.

Since:

BlackBerry 10.0.0

QVariantMap customHttpHeaders ()

Get a map of custom HTTP headers that will be added to every outgoing network request.

An empty map indicates no custom HTTP headers are in use.

Return:

A map where each key value pair corresponds to an HTTP header

Since:

BlackBerry 10.0.0

Q_SLOT void setCustomHttpHeaders (

Set a map of custom HTTP headers to be added to every outgoing network request.

Parameters
httpHeaders

A QVariantMap where each key value pair corresponds to an HTTP header.

Since:

BlackBerry 10.0.0

Q_SLOT void resetCustomHttpHeaders ()

Resets the custom HTTP headers to an empty map.

Since:

BlackBerry 10.0.0

double devicePixelRatio ()

Get device pixel ratio.

Since:

BlackBerry 10.0.0

Q_SLOT void setDevicePixelRatio (
  • doubleratio)

Set device pixel ratio.

Parameters
ratio

A pixel ratio.

Since:

BlackBerry 10.0.0

Q_SLOT void resetDevicePixelRatio ()

Reset device pixel ratio to default value.

Default value is the ratio between physical pixels and dips on the device.

Since:

BlackBerry 10.0.0

bool isCredentialAutoFillEnabled ()

Get whether or not credentials are automatically filled if available.

Since:

BlackBerry 10.1.0

Q_SLOT void setCredentialAutoFillEnabled (
  • boolenabled)

Set whether or not credentials are automatically filled if available.

Parameters
enabled

Set true to enable credential auto fill.

Since:

BlackBerry 10.1.0

Q_SLOT void resetCredentialAutoFillEnabled ()

Resets credential auto fill to default.

Since:

BlackBerry 10.1.0

bool isFormAutoFillEnabled ()

Get whether or not credentials are automatically filled if available.

Since:

BlackBerry 10.1.0

Q_SLOT void setFormAutoFillEnabled (
  • boolenabled)

Set whether or not credentials are automatically filled if available.

Parameters
enabled

Set true to enable credential auto fill.

Since:

BlackBerry 10.1.0

Q_SLOT void resetFormAutoFillEnabled ()

Resets credential auto fill to default.

Since:

BlackBerry 10.1.0

QString defaultTextCodecName ()

Get the default character encoding.

Since:

BlackBerry 10.1.0

Q_SLOT void setDefaultTextCodecName (

Set a default character encoding.

Parameters
codec

The encoding to be used when no other encoding information is available.

Since:

BlackBerry 10.1.0

Q_SLOT void resetDefaultTextCodecName ()

Reset back to default encoding of ISO-8859-1.

Since:

BlackBerry 10.1.0

Signals

void defaultFontSizeChanged (
  • intnewDefaultFontSize)

Emitted when the default font size changes.

Parameters
newDefaultFontSize

The new default font size

Since:

BlackBerry 10.0.0

void defaultFontSizeFollowsSystemFontSizeChanged (
  • boolnewDefaultFontSizeFollowsSystemFontSize)

Emitted when default font size begins or ends following system font size.

Parameters
newDefaultFontSizeFollowsSystemFontSize

The new value of the setting.

Since:

BlackBerry 10.0.0

void javaScriptEnabledChanged (
  • boolenabled)

Emitted when JavaScript enabled changes.

Parameters
enabled

Whether JavaScript is enabled or not

Since:

BlackBerry 10.0.0

void imageDownloadingEnabledChanged (
  • boolenabled)

Emitted when image downloading enabled changes.

Parameters
enabled

Whether image downloading is enabled or not

Since:

BlackBerry 10.0.0

void minimumFontSizeChanged (
  • intnewMinimumFontSize)

Emitted when the minimum font size changes.

Parameters
newMinimumFontSize

The new minimum font size

Since:

BlackBerry 10.0.0

void userAgentChanged (

Emitted when the user agent string changes.

Parameters
newUserAgent

The new user agent string

Since:

BlackBerry 10.0.0

void userStyleSheetLocationChanged (
  • QUrlnewUserStyleSheetLocation)

Emitted when the user style sheet location changes.

Parameters
newUserStyleSheetLocation

The new user style sheet location

Since:

BlackBerry 10.0.0

void webInspectorEnabledChanged (
  • boolenabled)

Emitted when web inspector enabled changes.

Parameters
enabled

Whether the web inspector is enabled or disabled

Since:

BlackBerry 10.0.0

void zoomToFitEnabledChanged (
  • boolenabled)

Emitted when zoom to fit enabled changes.

Parameters
enabled

Whether zoom to fit is enabled or disabled

Since:

BlackBerry 10.0.0

bool activeTextEnabledChanged (
  • boolenabled)

Emitted when active text matching enabled changes.

Parameters
enabled

Whether active text matching is enabled or disabled

Since:

BlackBerry 10.0.0

void viewportArgumentsChanged (

Emitted when the map of user viewport arguments changes.

Parameters
newViewportArguments

The new map of user viewport arguments

Since:

BlackBerry 10.0.0

void backgroundChanged (

Emitted when the background setting changes.

The newBackground QVariant provided wraps a bb::cascades::Paint instance.

Parameters
newBackground

The new background

Since:

BlackBerry 10.0.0

void binaryFontDownloadingEnabledChanged (
  • boolenabled)

Emitted when web font downloading enabled changed.

Parameters
enabled

Whether web font downloading is enabled or disabled.

Since:

BlackBerry 10.0.0

void cookiesEnabledChanged (
  • boolenabled)

Emitted when cookies enabled changed.

Parameters
enabled

Whether cookies are enabled or disabled.

Since:

BlackBerry 10.0.0

void customHttpHeadersChanged (

Emitted when the custom HTTP headers change.

Parameters
newCustomHttpHeaders

The new custom HTTP headers

Since:

BlackBerry 10.0.0

void devicePixelRatioChanged (
  • doublenewDevicePixelRatio)

Emitted when the device pixel ratio changes.

Parameters
newDevicePixelRatio

The new device pixel ratio

Since:

BlackBerry 10.0.0

void credentialAutoFillEnabledChanged (
  • boolenabled)

Emitted when credential auto fill changes.

Parameters
enabled

Whether credential auto fill is enabled.

Since:

BlackBerry 10.1.0

void formAutoFillEnabledChanged (
  • boolenabled)

Emitted when form auto fill changes.

Parameters
enabled

Whether form auto fill is enabled.

Since:

BlackBerry 10.1.0

void defaultTextCodecNameChanged (

Emitted when the default character encoding changes.

Parameters
codec

The new default character encoding.

Since:

BlackBerry 10.1.0