Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QPixmapCache Class Reference

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

Inheritance diagram for QtGui.QPixmapCache:
Collaboration diagram for QtGui.QPixmapCache:

Classes

class  Key
 The QPixmapCache::Key class can be used for efficient access to the QPixmapCache. More...
 

Public Member Functions

 QPixmapCache ()
 
 QPixmapCache (QPixmapCache copy)
 
virtual void CreateProxy ()
 
new void Dispose ()
 

Static Public Member Functions

static void Clear ()
 
 
static bool Find (QPixmapCache.Key key, QPixmap pixmap)
 
 
static QPixmap Find (string key)
 
 
static bool Find (string key, QPixmap pixmap)
 
 
static QPixmapCache.Key Insert (QPixmap pixmap)
 
 
static bool Insert (string key, QPixmap pixmap)
 
 
static void Remove (QPixmapCache.Key key)
 
 
static void Remove (string key)
 
 
static bool Replace (QPixmapCache.Key key, QPixmap pixmap)
 
 

Protected Member Functions

 QPixmapCache (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

static int CacheLimit [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

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 user-provided string as a key, or with a QPixmapCache::Key that the cache generates. Using QPixmapCache::Key for keys is faster than using strings. The string API is very convenient for complex keys but the QPixmapCache::Key API will be very efficient and convenient for a one-to-one object-to-pixmap mapping — in this case, you can store the keys as members of an object.

If two pixmaps are inserted into the cache using equal keys then the last pixmap will replace the first pixmap in the cache. This follows the behavior of the QHash and QCache classes.

The cache becomes full when the total size of all pixmaps in the cache exceeds cacheLimit(). The initial cache limit is 2048 KB (2 MB) on embedded platforms, 10240 KB (10 MB) on desktop platforms; you can change this by calling setCacheLimit() with the required value. 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.

Constructor & Destructor Documentation

QtGui.QPixmapCache.QPixmapCache ( System.Type  dummy)
protected
QtGui.QPixmapCache.QPixmapCache ( )
QtGui.QPixmapCache.QPixmapCache ( QPixmapCache  copy)

Member Function Documentation

static void QtGui.QPixmapCache.Clear ( )
static

Removes all pixmaps from the cache.

virtual void QtGui.QPixmapCache.CreateProxy ( )
virtual
new void QtGui.QPixmapCache.Dispose ( )
static bool QtGui.QPixmapCache.Find ( QPixmapCache.Key  key,
QPixmap  pixmap 
)
static

Looks for a cached pixmap associated with the given key in the cache. If the pixmap is found, the function sets pixmap to that pixmap and returns true; otherwise it leaves pixmap alone and returns false. If the pixmap is not found, it means that the key is no longer valid, so it will be released for the next insertion.

This function was introduced in Qt 4.6.

static QPixmap QtGui.QPixmapCache.Find ( string  key)
static

Looks for a cached pixmap associated with the given key in the cache. If the pixmap is found, the function sets pixmap to that pixmap and returns true; otherwise it leaves pixmap 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);

This function was introduced in Qt 4.6.

static bool QtGui.QPixmapCache.Find ( string  key,
QPixmap  pixmap 
)
static

Looks for a cached pixmap associated with the given key in the cache. If the pixmap is found, the function sets pixmap to that pixmap and returns true; otherwise it leaves pixmap 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);

This function was introduced in Qt 4.6.

static QPixmapCache.Key QtGui.QPixmapCache.Insert ( QPixmap  pixmap)
static

Inserts a copy of the given pixmap into the cache and returns a key that can be used to retrieve it.

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.

This function was introduced in Qt 4.6.

See also setCacheLimit() and replace().

static bool QtGui.QPixmapCache.Insert ( string  key,
QPixmap  pixmap 
)
static

Inserts a copy of the pixmap pixmap 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().

static void QtGui.QPixmapCache.Remove ( QPixmapCache.Key  key)
static

Removes the pixmap associated with key from the cache and releases the key for a future insertion.

This function was introduced in Qt 4.6.

static void QtGui.QPixmapCache.Remove ( string  key)
static

Removes the pixmap associated with key from the cache.

static bool QtGui.QPixmapCache.Replace ( QPixmapCache.Key  key,
QPixmap  pixmap 
)
static

Replaces the pixmap associated with the given key with the pixmap specified. Returns true if the pixmap has been correctly inserted into the cache; otherwise returns false.

This function was introduced in Qt 4.6.

See also setCacheLimit() and insert().

Member Data Documentation

SmokeInvocation QtGui.QPixmapCache.interceptor
protected

Property Documentation

int QtGui.QPixmapCache.CacheLimit
staticgetset

Returns the cache limit (in kilobytes).

The default cache limit is 2048 KB on embedded platforms, 10240 KB on desktop platforms.

Sets the cache limit to n kilobytes.

The default setting is 2048 KB on embedded platforms, 10240 KB on desktop platforms.

virtual System.IntPtr QtGui.QPixmapCache.SmokeObject
getset