|  | Home · Overviews · Examples

# QPixmapCache Class Reference
[com.trolltech.qt.gui module]

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

## 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`.