Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QWebSettings Class Reference
[QtWebKit module]

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

 #include <QWebSettings>

This class is not part of the Qt GUI Framework Edition.

This class was introduced in Qt 4.4.


Public Types

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

Public Functions

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

Static Public Members

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 )

Related Non-Members

void enablePersistentStorage ( const QString & path = QString() )
QString localStoragePath () const
QString offlineWebApplicationCachePath ()
void setLocalStoragePath ( const QString & path )
void setOfflineWebApplicationCachePath ( const QString & path )

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 globalSettings().

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 the setAttribute() function. The WebAttribute enum further describes each attribute.

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.

Enabling Plugins

Support for browser plugins can enabled by setting the PluginsEnabled attribute. For many applications, this attribute is enabled for all pages by setting it on the global settings object.

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 Web Browser.


Member Type Documentation

enum QWebSettings::FontFamily

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

ConstantValue
QWebSettings::StandardFont0
QWebSettings::FixedFont1
QWebSettings::SerifFont2
QWebSettings::SansSerifFont3
QWebSettings::CursiveFont4
QWebSettings::FantasyFont5

enum QWebSettings::FontSize

This enum describes the font sizes configurable through QWebSettings.

ConstantValueDescription
QWebSettings::MinimumFontSize0The hard minimum font size.
QWebSettings::MinimumLogicalFontSize1The minimum logical font size that is applied after zooming with QWebFrame's textSizeMultiplier().
QWebSettings::DefaultFontSize2The default font size for regular text.
QWebSettings::DefaultFixedFontSize3The default font size for fixed-pitch text.

enum QWebSettings::WebAttribute

This enum describes various attributes that are configurable through QWebSettings.

ConstantValueDescription
QWebSettings::AutoLoadImages0Specifies whether images are automatically loaded in web pages.
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.
QWebSettings::JavascriptEnabled1Enables or disables the running of JavaScript programs.
QWebSettings::JavaEnabled2Enables or disables Java applets. Currently Java applets are not supported.
QWebSettings::PluginsEnabled3Enables or disables plugins in Web pages.
QWebSettings::PrivateBrowsingEnabled4Private browsing prevents WebKit from recording visited pages in the history and storing web page icons.
QWebSettings::JavascriptCanOpenWindows5Specifies whether JavaScript programs can open new windows.
QWebSettings::JavascriptCanAccessClipboard6Specifies whether JavaScript programs can read or write to the clipboard.
QWebSettings::DeveloperExtrasEnabled7Enables extra tools for Web developers. Currently this enables the "Inspect" element in the context menu as well as the use of QWebInspector which controls the WebKit WebInspector for web site debugging.
QWebSettings::LinksIncludedInFocusChain8Specifies whether hyperlinks should be included in the keyboard focus chain.
QWebSettings::ZoomTextOnly9Specifies whether the zoom factor on a frame applies to only the text or all content.
QWebSettings::PrintElementBackgrounds10Specifies whether the background color and images are also drawn when the page is printed.
QWebSettings::OfflineStorageDatabaseEnabled11Specifies whether support for the HTML 5 offline storage feature is enabled or not. Disabled by default.
QWebSettings::OfflineWebApplicationCacheEnabled12Specifies whether support for the HTML 5 web application cache feature is enabled or not. Disabled by default.
QWebSettings::LocalStorageEnabled13Specifies whether support for the HTML 5 local storage feature is enabled or not. Disabled by default.
QWebSettings::LocalStorageDatabaseEnabledLocalStorageEnabledThis enum value is deprecated. Use QWebSettings::LocalStorageEnabled instead.
QWebSettings::LocalContentCanAccessRemoteUrls?Specifies whether locally loaded documents are allowed to access remote urls.

enum QWebSettings::WebGraphic

This enums describes the standard graphical elements used in webpages.

ConstantValueDescription
QWebSettings::MissingImageGraphic0The replacement graphic shown when an image could not be loaded.
QWebSettings::MissingPluginGraphic1The replacement graphic shown when a plugin could not be loaded.
QWebSettings::DefaultFrameIconGraphic2The default icon for QWebFrame::icon().
QWebSettings::TextAreaSizeGripCornerGraphic3The graphic shown for the size grip of text areas.


Member Function Documentation

void QWebSettings::clearIconDatabase ()   [static]

Clears the icon database.

void QWebSettings::clearMemoryCaches ()   [static]

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.

QString QWebSettings::defaultTextEncoding () const

Returns the default text encoding.

This function was introduced in Qt 4.6.

See also setDefaultTextEncoding().

void QWebSettings::enablePersistentStorage ( const QString & path = QString() )   [static]

Enables WebKit persistent data and sets the path to path. If the path is empty the path for persistent data is set to the user-specific data location specified by DataLocation.

This function was introduced in Qt 4.6.

See also localStoragePath().

QString QWebSettings::fontFamily ( FontFamily which ) const

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

See also setFontFamily().

int QWebSettings::fontSize ( FontSize type ) const

Returns the default font size for type.

See also setFontSize().

QWebSettings * QWebSettings::globalSettings ()   [static]

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 ()   [static]

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 ( const QUrl & url )   [static]

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().

QString QWebSettings::localStoragePath () const

Returns the path for HTML5 local storage.

This function was introduced in Qt 4.6.

See also setLocalStoragePath().

int QWebSettings::maximumPagesInCache ()   [static]

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

See also setMaximumPagesInCache().

qint64 QWebSettings::offlineStorageDefaultQuota ()   [static]

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 ()   [static]

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().

QString QWebSettings::offlineWebApplicationCachePath ()   [static]

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 also setOfflineWebApplicationCachePath().

qint64 QWebSettings::offlineWebApplicationCacheQuota ()   [static]

Returns the value of the quota for the offline web application cache.

This function was introduced in Qt 4.6.

See also setOfflineWebApplicationCacheQuota().

void QWebSettings::resetAttribute ( WebAttribute attribute )

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

See also globalSettings().

void QWebSettings::resetFontFamily ( 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.

void QWebSettings::resetFontSize ( 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.

void QWebSettings::setAttribute ( WebAttribute attribute, bool on )

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

void QWebSettings::setDefaultTextEncoding ( const QString & encoding )

Specifies the default text encoding system.

The encoding, 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 see QTextCodec

This function was introduced in Qt 4.6.

See also defaultTextEncoding().

void QWebSettings::setFontFamily ( FontFamily which, const QString & family )

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

See also fontFamily().

void QWebSettings::setFontSize ( FontSize type, int size )

Sets the font size for type to size.

See also fontSize().

void QWebSettings::setIconDatabasePath ( const QString & path )   [static]

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().

void QWebSettings::setLocalStoragePath ( const QString & path )

Sets the path for HTML5 local storage to path.

For more information on HTML5 local storage see the Web Storage standard.

Support for local storage can enabled by setting the LocalStorageEnabled attribute.

This function was introduced in Qt 4.6.

See also localStoragePath().

void QWebSettings::setMaximumPagesInCache ( int pages )   [static]

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

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 to pages per page group.

For more information about the feature, please refer to:

http://webkit.org/blog/427/webkit-page-cache-i-the-basics/

See also maximumPagesInCache().

void QWebSettings::setObjectCacheCapacities ( int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity )   [static]

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.

void QWebSettings::setOfflineStorageDefaultQuota ( qint64 maximumSize )   [static]

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().

void QWebSettings::setOfflineStoragePath ( const QString & path )   [static]

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().

void QWebSettings::setOfflineWebApplicationCachePath ( const QString & path )   [static]

Sets the path for HTML5 offline web application cache storage to path.

An application cache acts like an HTTP cache in some sense. For documents that use the application cache via JavaScript, the loader mechinery 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 where the cache is stored.

Setting an empty path disables the feature.

This function was introduced in Qt 4.6.

See also offlineWebApplicationCachePath().

void QWebSettings::setOfflineWebApplicationCacheQuota ( qint64 maximumSize )   [static]

Sets the value of the quota for the offline web application cache to maximumSize.

This function was introduced in Qt 4.6.

See also offlineWebApplicationCacheQuota().

void QWebSettings::setUserStyleSheetUrl ( const QUrl & location )

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

The location 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==;"

See also userStyleSheetUrl().

void QWebSettings::setWebGraphic ( WebGraphic type, const QPixmap & graphic )   [static]

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 ( WebAttribute attribute ) const

Returns true if attribute is enabled; otherwise returns false.

QUrl QWebSettings::userStyleSheetUrl () const

Returns the location of the user stylesheet.

See also setUserStyleSheetUrl().

QPixmap QWebSettings::webGraphic ( WebGraphic type )   [static]

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().


Related Non-Members

void QWebSettings::enablePersistentStorage ( const QString & path = QString() )   [static]

Enables WebKit persistent data and sets the path to path. If the path is empty the path for persistent data is set to the user-specific data location specified by DataLocation.

This function was introduced in Qt 4.6.

See also localStoragePath().

QString QWebSettings::localStoragePath () const

Returns the path for HTML5 local storage.

This function was introduced in Qt 4.6.

See also setLocalStoragePath().

QString QWebSettings::offlineWebApplicationCachePath ()   [static]

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 also setOfflineWebApplicationCachePath().

void QWebSettings::setLocalStoragePath ( const QString & path )

Sets the path for HTML5 local storage to path.

For more information on HTML5 local storage see the Web Storage standard.

Support for local storage can enabled by setting the LocalStorageEnabled attribute.

This function was introduced in Qt 4.6.

See also localStoragePath().

void QWebSettings::setOfflineWebApplicationCachePath ( const QString & path )   [static]

Sets the path for HTML5 offline web application cache storage to path.

An application cache acts like an HTTP cache in some sense. For documents that use the application cache via JavaScript, the loader mechinery 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 where the cache is stored.

Setting an empty path disables the feature.

This function was introduced in Qt 4.6.

See also offlineWebApplicationCachePath().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Quarterly au hasard

Logo

Déployer dans le Bazaar

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web