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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QPixmapCache Class Reference
[QtGui module]

The QPixmapCache class provides an application-wide cache for pixmaps. More...

#include <QPixmapCache>

Static Public Members


Detailed Description

The QPixmapCache class provides an application-wide cache for pixmaps.

This class is a tool for optimized drawing with QPixmap. You can use it to store temporary pixmaps that are expensive to generate without using more storage space than cacheLimit(). Use insert() to insert pixmaps, find() to find them, and clear() to empty the cache.

QPixmapCache contains no member data, only static functions to access the global pixmap cache. It creates an internal QCache object for caching the pixmaps.

The cache associates a pixmap with a string (key). If two pixmaps are inserted into the cache using equal keys, then the last pixmap will hide the first pixmap. The QHash and QCache classes do exactly the same.

The cache becomes full when the total size of all pixmaps in the cache exceeds cacheLimit(). The initial cache limit is 1024 KB (1 MB); it is changed with setCacheLimit(). A pixmap takes roughly (width * height * depth)/8 bytes of memory.

The Qt Quarterly article Optimizing with QPixmapCache explains how to use QPixmapCache to speed up applications by caching the results of painting.

See also QCache and QPixmap.


Member Function Documentation

int QPixmapCache::cacheLimit ()   [static]

Returns the cache limit (in kilobytes).

The default setting is 1024 kilobytes.

See also setCacheLimit().

void QPixmapCache::clear ()   [static]

Removes all pixmaps from the cache.

bool QPixmapCache::find ( const QString & key, QPixmap & pm )   [static]

Looks for a cached pixmap associated with the key in the cache. If the pixmap is found, the function sets pm to that pixmap and returns true; otherwise it leaves pm alone and returns false.

Example:

    QPixmap pm;
    if (!QPixmapCache::find("my_big_image", pm)) {
        pm.load("bigimage.png");
        QPixmapCache::insert("my_big_image", pm);
    }
    painter->drawPixmap(0, 0, pm);

bool QPixmapCache::insert ( const QString & key, const QPixmap & pm )   [static]

Inserts a copy of the pixmap pm associated with the key into the cache.

All pixmaps inserted by the Qt library have a key starting with "$qt", so your own pixmap keys should never begin "$qt".

When a pixmap is inserted and the cache is about to exceed its limit, it removes pixmaps until there is enough room for the pixmap to be inserted.

The oldest pixmaps (least recently accessed in the cache) are deleted when more space is needed.

The function returns true if the object was inserted into the cache; otherwise it returns false.

See also setCacheLimit().

void QPixmapCache::remove ( const QString & key )   [static]

Removes the pixmap associated with key from the cache.

void QPixmapCache::setCacheLimit ( int n )   [static]

Sets the cache limit to n kilobytes.

The default setting is 1024 kilobytes.

See also cacheLimit().

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.1
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