QPixmapCache Class Reference


The QPixmapCache class provides an application-global cache for pixmaps. (details) (complete member list)

#include <qpmcache.h>

Static Public Members


Detailed Description

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

The QPixmapCache is a class that contains no real members, only static functions to access the global pixmap cache. It creates an internal QCache for caching the pixmaps.

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

The cache becomes full when the total size of all pixmaps in the cache exceeds the cache limit. The initial cache limit is 1024 KByte (1 MByte). A pixmap takes roughly width*height*depth/8 bytes of memory.

See the QCache documentation for a more details about the cache mechanism.


Member Function Documentation

int QPixmapCache::cacheLimit ()

Returns the cache limit (in kilobytes).

See also: setCacheLimit().

void QPixmapCache::clear ()

Removes all pixmaps from the cache.

QPixmap * QPixmapCache::find (const char *key)

Returns the pixmap associated with key in the cache, or 0 if there is no such pixmap.

bool QPixmapCache::insert (const char *key, QPixmap *pm)

Inserts the pixmap pm associated with key into the cache. Returns TRUE if successful, or FALSE if the pixmap is too big for the cache.

All pixmaps inserted by the Qt library has a key starting with "$qt.." (so let your keys start with something else).

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) will be thrown away when more space is needed.

See also: setCacheLimit().

void QPixmapCache::setCacheLimit (int n)

Sets the cache limit to n kilobytes.

The default setting is 1024 kilobytes.

See also: cacheLimit().


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech