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
|
<?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>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 <i>key</i>)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#find-2">find</a></b> (QString <i>key</i>, QPixmap)</li><li><div class="fn" />bool <b><a href="qpixmapcache.html#insert">insert</a></b> (QString <i>key</i>, QPixmap)</li><li><div class="fn" /><b><a href="qpixmapcache.html#remove">remove</a></b> (QString <i>key</i>)</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 string (key). If two pixmaps are inserted into the cache using equal keys, then the last pixmap will hide the first pixmap. The <a href="qhash.html">QHash</a> and <a href="qcache.html">QCache</a> classes do exactly the same.</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 1024 KB (1 MB); it is changed with <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>(). 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://doc.trolltech.com/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 setting is 1024 kilobytes.</p>
<p>See also <a href="qpixmapcache.html#setCacheLimit">setCacheLimit</a>().</p>
<h3 class="fn"><a name="clear" />QPixmapCache.clear ()</h3><p>Removes all pixmaps from the cache.</p>
<h3 class="fn"><a name="find" /><a href="qpixmap.html">QPixmap</a> QPixmapCache.find (<a href="qstring.html">QString</a> <i>key</i>)</h3><p>Looks for a cached pixmap associated with the <i>key</i> in the cache. If the pixmap is found, the function sets <i>pm</i> to that pixmap and returns true; otherwise it leaves <i>pm</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>
<h3 class="fn"><a name="find-2" />bool QPixmapCache.find (<a href="qstring.html">QString</a> <i>key</i>, <a href="qpixmap.html">QPixmap</a>)</h3><h3 class="fn"><a name="insert" />bool QPixmapCache.insert (<a href="qstring.html">QString</a> <i>key</i>, <a href="qpixmap.html">QPixmap</a>)</h3><p>Inserts a copy of the pixmap <i>pm</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="remove" />QPixmapCache.remove (<a href="qstring.html">QString</a> <i>key</i>)</h3><p>Removes the pixmap associated with <i>key</i> from the cache.</p>
<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 1024 kilobytes.</p>
<p>See also <a href="qpixmapcache.html#cacheLimit">cacheLimit</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|