⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpixmapcache.html

📁 QT 下载资料仅供参考
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qpixmapcache.cpp:45 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QPixmapCache Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPixmapCache Class Reference</h1><p>The QPixmapCache class provides an application-global cache forpixmaps.<a href="#details">More...</a><p><tt>#include &lt;<a href="qpixmapcache-h.html">qpixmapcache.h</a>&gt;</tt><p><a href="qpixmapcache-members.html">List of all member functions.</a><h2>Static Public Members</h2><ul><li><div class=fn>int <a href="#cacheLimit"><b>cacheLimit</b></a> ()</div></li><li><div class=fn>void <a href="#setCacheLimit"><b>setCacheLimit</b></a> ( int&nbsp;n )</div></li><li><div class=fn>QPixmap * <a href="#find"><b>find</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key )</div></li><li><div class=fn>bool <a href="#find-2"><b>find</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, QPixmap&nbsp;&amp;&nbsp;pm )</div></li><li><div class=fn>bool insert ( const&nbsp;QString&nbsp;&amp;&nbsp;key, QPixmap&nbsp;*&nbsp;pm ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>bool <a href="#insert"><b>insert</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pm )</div></li><li><div class=fn>void <a href="#clear"><b>clear</b></a> ()</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2><p> The QPixmapCache class provides an application-global cache forpixmaps.<p> <p> This class is a tool for optimized drawing with <a href="qpixmap.html">QPixmap</a>. You canuse it to store temporary pixmaps that are expensive to generatewithout using more storage space than <a href="#cacheLimit">cacheLimit</a>(). Use <a href="#insert">insert</a>()to insert pixmaps, <a href="#find">find</a>() to find them and <a href="#clear">clear</a>() to empty thecache.<p> For example, <a href="qradiobutton.html">QRadioButton</a> has a non-trivial visual representationso we don't want to regenerate a pixmap whenever a radio button isdisplayed or changes state. In the function<a href="qbutton.html#drawButton">QRadioButton::drawButton</a>(), we do not draw the radio buttondirectly. Instead, we first check the global pixmap cache for apixmap with the key "$qt_radio_nnn_", where <tt>nnn</tt> is a numericalvalue that specifies the the radio button state. If a pixmap isfound, we <a href="qpaintdevice.html#bitBlt-2">bitBlt</a>() it onto the widget and return. Otherwise, wecreate a new pixmap, draw the radio button in the pixmap, andfinally insert the pixmap in the global pixmap cache, using thekey above. The bitBlt() is ten times faster than drawing theradio button. All radio buttons in the program share the cachedpixmap since QPixmapCache is application-global.<p> QPixmapCache contains no member data, only static functions toaccess the global pixmap cache. It creates an internal <a href="qcache.html">QCache</a> forcaching the pixmaps.<p> The cache associates a pixmap with a string (key). If two pixmapsare inserted into the cache using equal keys, then the last pixmapwill hide the first pixmap. The <a href="qdict.html">QDict</a> and QCache classes doexactly the same.<p> The cache becomes full when the total size of all pixmaps in thecache exceeds <a href="#cacheLimit">cacheLimit</a>(). The initial cache limit is 1024 KByte(1 MByte); it is changed with <a href="#setCacheLimit">setCacheLimit</a>(). A pixmap takesroughly width*height*depth/8 bytes of memory.<p> See the <a href="qcache.html">QCache</a> documentation for more details about the cachemechanism.<p>See also <a href="environment.html">Environment Classes</a>, <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.<hr><h2>Member Function Documentation</h2><h3 class=fn>int <a name="cacheLimit"></a>QPixmapCache::cacheLimit ()<tt> [static]</tt></h3>Returns the cache limit (in kilobytes).<p> The default setting is 1024 kilobytes.<p> <p>See also <a href="#setCacheLimit">setCacheLimit</a>().<h3 class=fn>void <a name="clear"></a>QPixmapCache::clear ()<tt> [static]</tt></h3>Removes all pixmaps from the cache.<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="find"></a>QPixmapCache::find ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key )<tt> [static]</tt></h3>Returns the pixmap associated with the <em>key</em> in the cache, ornull if there is no such pixmap.<p> <b>Warning:</b> If valid, you should copy the pixmap immediately (this isfast). Subsequent insertions into the cache could cause thepointer to become invalid. For this reason, we recommend you use<a href="#find">find</a>(const <a href="qstring.html">QString</a>&, <a href="qpixmap.html">QPixmap</a>&) instead.<p> Example:<pre>        <a href="qpixmap.html">QPixmap</a>* pp;        <a href="qpixmap.html">QPixmap</a> p;        if ( (pp=QPixmapCache::<a href="#find">find</a>("my_big_image", pm)) ) {            p = *pp;        } else {            p.<a href="qpixmap.html#load">load</a>("bigimage.png");            QPixmapCache::<a href="#insert">insert</a>("my_big_image", new <a href="qpixmap.html">QPixmap</a>(p));        }        painter-&gt;drawPixmap(0, 0, p);    </pre> <h3 class=fn>bool <a name="find-2"></a>QPixmapCache::find ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, <a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pm )<tt> [static]</tt></h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Looks for a cached pixmap associated with the <em>key</em> in the cache.If a pixmap is found, the function sets <em>pm</em> to that pixmap andreturns TRUE; otherwise leaves <em>pm</em> alone and returns FALSE.<p> Example:<pre>        <a href="qpixmap.html">QPixmap</a> p;        if ( !QPixmapCache::find("my_big_image", pm) ) {            pm.load("bigimage.png");            QPixmapCache::<a href="#insert">insert</a>("my_big_image", pm);        }        painter-&gt;drawPixmap(0, 0, p);    </pre> <h3 class=fn>bool <a name="insert"></a>QPixmapCache::insert ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pm )<tt> [static]</tt></h3>Inserts a copy of the pixmap <em>pm</em> associated with the <em>key</em> intothe cache.<p> All pixmaps inserted by the Qt library have a key starting with"$qt", so your own pixmap keys should never begin "$qt".<p> When a pixmap is inserted and the cache is about to exceed itslimit, it removes pixmaps until there is enough room for thepixmap to be inserted.<p> The oldest pixmaps (least recently accessed in the cache) aredeleted when more space is needed.<p> <p>See also <a href="#setCacheLimit">setCacheLimit</a>().<h3 class=fn>bool <a name="insert-2"></a>QPixmapCache::insert ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, <a href="qpixmap.html">QPixmap</a>&nbsp;*&nbsp;pm )<tt> [static]</tt></h3><b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.<p> Inserts the pixmap <em>pm</em> associated with <em>key</em> into the cache.Returns TRUE if successful, or FALSE if the pixmap is too big for the cache.<p> <strong>Note: <em>pm</em> must be allocated on the heap (using <tt>new</tt>).<p> If this function returns FALSE, you must delete <em>pm</em> yourself.<p> If this function returns TRUE, do not use <em>pm</em> afterwards orkeep references to it because any other insertions into the cache,whether from anywhere in the application or within Qt itself, could causethe pixmap to be discarded from the cache and the pointer tobecome invalid.<p> Due to these dangers, we strongly recommend that you use<a href="#insert">insert</a>(const <a href="qstring.html">QString</a>&, const <a href="qpixmap.html">QPixmap</a>&) instead.</strong><h3 class=fn>void <a name="setCacheLimit"></a>QPixmapCache::setCacheLimit ( int&nbsp;n )<tt> [static]</tt></h3>Sets the cache limit to <em>n</em> kilobytes.<p> The default setting is 1024 kilobytes.<p> <p>See also <a href="#cacheLimit">cacheLimit</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright &copy; 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -