1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QPixmapCache Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QPixmapCache Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPixmapCache class provides an application-wide cache for pixmaps. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />class <b><a href="qpixmapcache-key.html">Key</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpixmapcache.html#QPixmapCache">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpixmapcache.html#QPixmapCache-2">__init__</a></b> (<i>self</i>, QPixmapCache)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int <b><a href="qpixmapcache.html#cacheLimit">cacheLimit</a></b> ()</li><li><div class="fn" /><b><a href="qpixmapcache.html#clear">clear</a></b> ()</li><li><div class="fn" />QPixmap <b><a href="qpixmapcache.html#find">find</a></b> (QString)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#find-2">find</a></b> (QString, QPixmap)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#find-3">find</a></b> (Key, QPixmap)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#insert">insert</a></b> (QString, QPixmap)</li><li><div class="fn" />Key <b><a href="qpixmapcache.html#insert-2">insert</a></b> (QPixmap)</li><li><div class="fn" /><b><a href="qpixmapcache.html#remove">remove</a></b> (QString)</li><li><div class="fn" /><b><a href="qpixmapcache.html#remove-2">remove</a></b> (Key)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#replace">replace</a></b> (Key, QPixmap)</li><li><div class="fn" /><b><a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a></b> (int)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QPixmapCache class provides an application-wide cache for pixmaps.</p>
<p>This class is a tool for optimized drawing with <a href="qpixmap.html">QPixmap</a>. You can use it to store temporary pixmaps that are expensive to generate without using more storage space than <a href="qpixmapcache.html#cacheLimit">cacheLimit</a>(). Use <a href="qpixmapcache.html#insert">insert</a>() to insert pixmaps, <a href="qpixmapcache.html#find">find</a>() to find them, and <a href="qpixmapcache.html#clear">clear</a>() to empty the cache.</p>
<p>QPixmapCache contains no member data, only static functions to access the global pixmap cache. It creates an internal <a href="qcache.html">QCache</a> object for caching the pixmaps.</p>
<p>The cache associates a pixmap with a user-provided string as a key, or with a <a href="qpixmapcache-key.html">QPixmapCache.Key</a> that the cache generates. Using <a href="qpixmapcache-key.html">QPixmapCache.Key</a> for keys is faster than using strings. The string API is very convenient for complex keys but the <a href="qpixmapcache-key.html">QPixmapCache.Key</a> API will be very efficient and convenient for a one-to-one object-to-pixmap mapping &#8212; in this case, you can store the keys as members of an object.</p>
<p>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 <a href="qhash.html">QHash</a> and <a href="qcache.html">QCache</a> classes.</p>
<p>The cache becomes full when the total size of all pixmaps in the cache exceeds <a href="qpixmapcache.html#cacheLimit">cacheLimit</a>(). 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 <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>() with the required value. A pixmap takes roughly (<i>width</i> * <i>height</i> * <i>depth</i>)/8 bytes of memory.</p>
<p>The <i>Qt Quarterly</i> article <a href="http://qt.nokia.com/doc/qq/qq12-qpixmapcache.html">Optimizing with QPixmapCache</a> explains how to use QPixmapCache to speed up applications by caching the results of painting.</p>
<p>See also <a href="qcache.html">QCache</a> and <a href="qpixmap.html">QPixmap</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPixmapCache" />QPixmapCache.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QPixmapCache-2" />QPixmapCache.__init__ (<i>self</i>, <a href="qpixmapcache.html">QPixmapCache</a>)</h3><h3 class="fn"><a name="cacheLimit" />int QPixmapCache.cacheLimit ()</h3><p>Returns the cache limit (in kilobytes).</p>
<p>The default cache limit is 2048 KB on embedded platforms, 10240 KB on desktop platforms.</p>
<p>See also <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>().</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/clear" />
<h3 class="fn"><a name="clear" />QPixmapCache.clear ()</h3><p>Removes all pixmaps from the cache.</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/find" />
<h3 class="fn"><a name="find" /><a href="qpixmap.html">QPixmap</a> QPixmapCache.find (QString)</h3><p>Looks for a cached pixmap associated with the given <i>key</i> in the cache. If the pixmap is found, the function sets <i>pixmap</i> to that pixmap and returns true; otherwise it leaves <i>pixmap</i> alone and returns false.</p>
<p>Example:</p>
<pre> QPixmap pm;
if (!QPixmapCache.find("my_big_image", &pm)) {
pm.load("bigimage.png");
QPixmapCache.insert("my_big_image", pm);
}
painter->drawPixmap(0, 0, pm);</pre>
<p>This function was introduced in Qt 4.6.</p>
<h3 class="fn"><a name="find-2" />bool QPixmapCache.find (QString, <a href="qpixmap.html">QPixmap</a>)</h3><h3 class="fn"><a name="find-3" />bool QPixmapCache.find (<a href="qpixmapcache-key.html">Key</a>, <a href="qpixmap.html">QPixmap</a>)</h3><p>Looks for a cached pixmap associated with the given <i>key</i> in the cache. If the pixmap is found, the function sets <i>pixmap</i> to that pixmap and returns true; otherwise it leaves <i>pixmap</i> alone and returns false. If the pixmap is not found, it means that the <i>key</i> is no longer valid, so it will be released for the next insertion.</p>
<p>This function was introduced in Qt 4.6.</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/insert" />
<h3 class="fn"><a name="insert" />bool QPixmapCache.insert (QString, <a href="qpixmap.html">QPixmap</a>)</h3><p>Inserts a copy of the pixmap <i>pixmap</i> associated with the <i>key</i> into the cache.</p>
<p>All pixmaps inserted by the Qt library have a key starting with "$qt", so your own pixmap keys should never begin "$qt".</p>
<p>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.</p>
<p>The oldest pixmaps (least recently accessed in the cache) are deleted when more space is needed.</p>
<p>The function returns true if the object was inserted into the cache; otherwise it returns false.</p>
<p>See also <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>().</p>
<h3 class="fn"><a name="insert-2" /><a href="qpixmapcache-key.html">Key</a> QPixmapCache.insert (<a href="qpixmap.html">QPixmap</a>)</h3><p>Inserts a copy of the given <i>pixmap</i> into the cache and returns a key that can be used to retrieve it.</p>
<p>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.</p>
<p>The oldest pixmaps (least recently accessed in the cache) are deleted when more space is needed.</p>
<p>This function was introduced in Qt 4.6.</p>
<p>See also <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>() and <a href="qpixmapcache.html#replace">replace</a>().</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/remove" />
<h3 class="fn"><a name="remove" />QPixmapCache.remove (QString)</h3><p>Removes the pixmap associated with <i>key</i> from the cache.</p>
<h3 class="fn"><a name="remove-2" />QPixmapCache.remove (<a href="qpixmapcache-key.html">Key</a>)</h3><p>Removes the pixmap associated with <i>key</i> from the cache and releases the key for a future insertion.</p>
<p>This function was introduced in Qt 4.6.</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/replace" />
<h3 class="fn"><a name="replace" />bool QPixmapCache.replace (<a href="qpixmapcache-key.html">Key</a>, <a href="qpixmap.html">QPixmap</a>)</h3><p>Replaces the pixmap associated with the given <i>key</i> with the <i>pixmap</i> specified. Returns true if the <i>pixmap</i> has been correctly inserted into the cache; otherwise returns false.</p>
<p>This function was introduced in Qt 4.6.</p>
<p>See also <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>() and <a href="qpixmapcache.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/clm/QPixmapCache/setCacheLimit" />
<h3 class="fn"><a name="setCacheLimit" />QPixmapCache.setCacheLimit (int)</h3><p>Sets the cache limit to <i>n</i> kilobytes.</p>
<p>The default setting is 2048 KB on embedded platforms, 10240 KB on desktop platforms.</p>
<p>See also <a href="qpixmapcache.html#cacheLimit">cacheLimit</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|