<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qiconengine.cpp --> <title>QIconEngine Class | Qt GUI 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QIconEngine</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QIconEngine Class</h1> <!-- $$$QIconEngine-brief --> <p>The <a href="qiconengine.html">QIconEngine</a> class provides an abstract base class for <a href="qicon.html">QIcon</a> renderers. <a href="#details">More...</a></p> <!-- @@@QIconEngine --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QIconEngine></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><ul> <li><a href="qiconengine-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qiconengine-availablesizesargument.html">AvailableSizesArgument</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qiconengine-scaledpixmapargument.html">ScaledPixmapArgument</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#IconEngineHook-enum">IconEngineHook</a></b> { AvailableSizesHook, IconNameHook, IsNullHook, ScaledPixmapHook }</td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#QIconEngine">QIconEngine</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#dtor.QIconEngine">~QIconEngine</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#actualSize">actualSize</a></b>(const QSize &<i>size</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#addFile">addFile</a></b>(const QString &<i>fileName</i>, const QSize &<i>size</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#addPixmap">addPixmap</a></b>(const QPixmap &<i>pixmap</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QList<QSize> </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#availableSizes">availableSizes</a></b>(QIcon::Mode <i>mode</i> = QIcon::Normal, QIcon::State <i>state</i> = QIcon::Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QIconEngine *</td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#clone">clone</a></b>() const = 0</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#iconName">iconName</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#isNull">isNull</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#key">key</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#paint">paint</a></b>(QPainter *<i>painter</i>, const QRect &<i>rect</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>) = 0</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#pixmap">pixmap</a></b>(const QSize &<i>size</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#read">read</a></b>(QDataStream &<i>in</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#scaledPixmap">scaledPixmap</a></b>(const QSize &<i>size</i>, QIcon::Mode <i>mode</i>, QIcon::State <i>state</i>, qreal <i>scale</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#virtual_hook">virtual_hook</a></b>(int <i>id</i>, void *<i>data</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qiconengine.html#write">write</a></b>(QDataStream &<i>out</i>) const</td></tr> </table></div> <a name="details"></a> <!-- $$$QIconEngine-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qiconengine.html">QIconEngine</a> class provides an abstract base class for <a href="qicon.html">QIcon</a> renderers.</p> <p>An icon engine provides the rendering functions for a <a href="qicon.html">QIcon</a>. Each icon has a corresponding icon engine that is responsible for drawing the icon with a requested size, mode and state.</p> <p>The icon is rendered by the <a href="qiconengine.html#paint">paint</a>() function, and the icon can additionally be obtained as a pixmap with the <a href="qiconengine.html#pixmap">pixmap</a>() function (the default implementation simply uses <a href="qiconengine.html#paint">paint</a>() to achieve this). The <a href="qiconengine.html#addPixmap">addPixmap</a>() function can be used to add new pixmaps to the icon engine, and is used by <a href="qicon.html">QIcon</a> to add specialized custom pixmaps.</p> <p>The <a href="qiconengine.html#paint">paint</a>(), <a href="qiconengine.html#pixmap">pixmap</a>(), and <a href="qiconengine.html#addPixmap">addPixmap</a>() functions are all virtual, and can therefore be reimplemented in subclasses of <a href="qiconengine.html">QIconEngine</a>.</p> </div> <p><b>See also </b><a href="qiconengineplugin.html">QIconEnginePlugin</a>.</p> <!-- @@@QIconEngine --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$IconEngineHook$$$AvailableSizesHook$$$IconNameHook$$$IsNullHook$$$ScaledPixmapHook --> <h3 class="fn" id="IconEngineHook-enum"><a name="IconEngineHook-enum"></a>enum QIconEngine::<span class="name">IconEngineHook</span></h3> <p>These enum values are used for <a href="qiconengine.html#virtual_hook">virtual_hook</a>() to allow additional queries to icon engine without breaking binary compatibility.</p> <div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr> <tr><td class="topAlign"><code>QIconEngine::AvailableSizesHook</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Allows to query the sizes of the contained pixmaps for pixmap-based engines. The <i>data</i> argument of the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() function is a <a href="qiconengine-availablesizesargument.html">AvailableSizesArgument</a> pointer that should be filled with icon sizes. Engines that work in terms of a scalable, vectorial format normally return an empty list.</td></tr> <tr><td class="topAlign"><code>QIconEngine::IconNameHook</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">Allows to query the name used to create the icon, for example when instantiating an icon using <a href="qicon.html#fromTheme">QIcon::fromTheme</a>().</td></tr> <tr><td class="topAlign"><code>QIconEngine::IsNullHook</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">Allow to query if this engine represents a null icon. The <i>data</i> argument of the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() is a pointer to a bool that can be set to true if the icon is null. This enum value was added in Qt 5.7.</td></tr> <tr><td class="topAlign"><code>QIconEngine::ScaledPixmapHook</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">Provides a way to get a pixmap that is scaled according to the given scale (typically equal to the device pixel ratio). The <i>data</i> argument of the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() function is a <a href="qiconengine-scaledpixmapargument.html">ScaledPixmapArgument</a> pointer that contains both the input and output arguments. This enum value was added in Qt 5.9.</td></tr> </table></div> <p>This enum was introduced or modified in Qt 4.5.</p> <p><b>See also </b><a href="qiconengine.html#virtual_hook">virtual_hook</a>().</p> <!-- @@@IconEngineHook --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QIconEngine[overload1]$$$QIconEngine --> <h3 class="fn" id="QIconEngine"><a name="QIconEngine"></a>QIconEngine::<span class="name">QIconEngine</span>()</h3> <p>Constructs the icon engine.</p> <p>This function was introduced in Qt 5.6.</p> <!-- @@@QIconEngine --> <!-- $$$~QIconEngine[overload1]$$$~QIconEngine --> <h3 class="fn" id="dtor.QIconEngine"><a name="dtor.QIconEngine"></a><code>[virtual] </code>QIconEngine::<span class="name">~QIconEngine</span>()</h3> <p>Destroys the icon engine.</p> <!-- @@@~QIconEngine --> <!-- $$$actualSize[overload1]$$$actualSizeconstQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="actualSize"><a name="actualSize"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QIconEngine::<span class="name">actualSize</span>(const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &<i>size</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>)</h3> <p>Returns the actual size of the icon the engine provides for the requested <i>size</i>, <i>mode</i> and <i>state</i>. The default implementation returns the given <i>size</i>.</p> <!-- @@@actualSize --> <!-- $$$addFile[overload1]$$$addFileconstQString&constQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="addFile"><a name="addFile"></a><code>[virtual] </code><span class="type">void</span> QIconEngine::<span class="name">addFile</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>fileName</i>, const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &<i>size</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>)</h3> <p>Called by <a href="qicon.html#addFile">QIcon::addFile</a>(). Adds a specialized pixmap from the file with the given <i>fileName</i>, <i>size</i>, <i>mode</i> and <i>state</i>. The default pixmap-based engine stores any supplied file names, and it loads the pixmaps on demand instead of using scaled pixmaps if the size of a pixmap matches the size of icon requested. Custom icon engines that implement scalable vector formats are free to ignores any extra files.</p> <!-- @@@addFile --> <!-- $$$addPixmap[overload1]$$$addPixmapconstQPixmap&QIcon::ModeQIcon::State --> <h3 class="fn" id="addPixmap"><a name="addPixmap"></a><code>[virtual] </code><span class="type">void</span> QIconEngine::<span class="name">addPixmap</span>(const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>)</h3> <p>Called by <a href="qicon.html#addPixmap">QIcon::addPixmap</a>(). Adds a specialized <i>pixmap</i> for the given <i>mode</i> and <i>state</i>. The default pixmap-based engine stores any supplied pixmaps, and it uses them instead of scaled pixmaps if the size of a pixmap matches the size of icon requested. Custom icon engines that implement scalable vector formats are free to ignores any extra pixmaps.</p> <!-- @@@addPixmap --> <!-- $$$availableSizes[overload1]$$$availableSizesQIcon::ModeQIcon::State --> <h3 class="fn" id="availableSizes"><a name="availableSizes"></a><code>[virtual] </code><span class="type">QList</span><<span class="type"><a href="../qtcore/qsize.html">QSize</a></span>> QIconEngine::<span class="name">availableSizes</span>(<span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i> = QIcon::Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = QIcon::Off) const</h3> <p>Returns sizes of all images that are contained in the engine for the specific <i>mode</i> and <i>state</i>.</p> <p><b>Note: </b>This is a helper method and the actual work is done by the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() method, hence this method depends on icon engine support and may not work with all icon engines.</p><p>This function was introduced in Qt 4.5.</p> <!-- @@@availableSizes --> <!-- $$$clone[overload1]$$$clone --> <h3 class="fn" id="clone"><a name="clone"></a><code>[pure virtual] </code><span class="type"><a href="qiconengine.html#QIconEngine">QIconEngine</a></span> *QIconEngine::<span class="name">clone</span>() const</h3> <p>Reimplement this method to return a clone of this icon engine.</p> <!-- @@@clone --> <!-- $$$iconName[overload1]$$$iconName --> <h3 class="fn" id="iconName"><a name="iconName"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QIconEngine::<span class="name">iconName</span>() const</h3> <p>Returns the name used to create the engine, if available.</p> <p><b>Note: </b>This is a helper method and the actual work is done by the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() method, hence this method depends on icon engine support and may not work with all icon engines.</p><p>This function was introduced in Qt 4.7.</p> <!-- @@@iconName --> <!-- $$$isNull[overload1]$$$isNull --> <h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QIconEngine::<span class="name">isNull</span>() const</h3> <p>Returns true if this icon engine represent a null <a href="qicon.html">QIcon</a>.</p> <p><b>Note: </b>This is a helper method and the actual work is done by the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() method, hence this method depends on icon engine support and may not work with all icon engines.</p><p>This function was introduced in Qt 5.7.</p> <!-- @@@isNull --> <!-- $$$key[overload1]$$$key --> <h3 class="fn" id="key"><a name="key"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QIconEngine::<span class="name">key</span>() const</h3> <p>Returns a key that identifies this icon engine.</p> <!-- @@@key --> <!-- $$$paint[overload1]$$$paintQPainter*constQRect&QIcon::ModeQIcon::State --> <h3 class="fn" id="paint"><a name="paint"></a><code>[pure virtual] </code><span class="type">void</span> QIconEngine::<span class="name">paint</span>(<span class="type"><a href="qpainter.html">QPainter</a></span> *<i>painter</i>, const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &<i>rect</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>)</h3> <p>Uses the given <i>painter</i> to paint the icon with the required <i>mode</i> and <i>state</i> into the rectangle <i>rect</i>.</p> <!-- @@@paint --> <!-- $$$pixmap[overload1]$$$pixmapconstQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="pixmap"><a name="pixmap"></a><code>[virtual] </code><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIconEngine::<span class="name">pixmap</span>(const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &<i>size</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>)</h3> <p>Returns the icon as a pixmap with the required <i>size</i>, <i>mode</i>, and <i>state</i>. The default implementation creates a new pixmap and calls <a href="qiconengine.html#paint">paint</a>() to fill it.</p> <!-- @@@pixmap --> <!-- $$$read[overload1]$$$readQDataStream& --> <h3 class="fn" id="read"><a name="read"></a><code>[virtual] </code><span class="type">bool</span> QIconEngine::<span class="name">read</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>in</i>)</h3> <p>Reads icon engine contents from the <a href="../qtcore/qdatastream.html">QDataStream</a> <i>in</i>. Returns true if the contents were read; otherwise returns <code>false</code>.</p> <p><a href="qiconengine.html">QIconEngine</a>'s default implementation always return false.</p> <!-- @@@read --> <!-- $$$scaledPixmap[overload1]$$$scaledPixmapconstQSize&QIcon::ModeQIcon::Stateqreal --> <h3 class="fn" id="scaledPixmap"><a name="scaledPixmap"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIconEngine::<span class="name">scaledPixmap</span>(const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &<i>size</i>, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i>, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>scale</i>)</h3> <p>Returns a pixmap for the given <i>size</i>, <i>mode</i>, <i>state</i> and <i>scale</i>.</p> <p>The <i>scale</i> argument is typically equal to the device pixel ratio of the display.</p> <p><b>Note: </b>This is a helper method and the actual work is done by the <a href="qiconengine.html#virtual_hook">virtual_hook</a>() method, hence this method depends on icon engine support and may not work with all icon engines.</p><p><b>Note: </b>Some engines may cast <i>scale</i> to an integer.</p><p>This function was introduced in Qt 5.9.</p> <p><b>See also </b><a href="qiconengine-scaledpixmapargument.html">ScaledPixmapArgument</a>.</p> <!-- @@@scaledPixmap --> <!-- $$$virtual_hook[overload1]$$$virtual_hookintvoid* --> <h3 class="fn" id="virtual_hook"><a name="virtual_hook"></a><code>[virtual] </code><span class="type">void</span> QIconEngine::<span class="name">virtual_hook</span>(<span class="type">int</span> <i>id</i>, <span class="type">void</span> *<i>data</i>)</h3> <p>Additional method to allow extending <a href="qiconengine.html">QIconEngine</a> without adding new virtual methods (and without breaking binary compatibility). The actual action and format of <i>data</i> depends on <i>id</i> argument which is in fact a constant from <a href="qiconengine.html#IconEngineHook-enum">IconEngineHook</a> enum.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also </b><a href="qiconengine.html#IconEngineHook-enum">IconEngineHook</a>.</p> <!-- @@@virtual_hook --> <!-- $$$write[overload1]$$$writeQDataStream& --> <h3 class="fn" id="write"><a name="write"></a><code>[virtual] </code><span class="type">bool</span> QIconEngine::<span class="name">write</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>out</i>) const</h3> <p>Writes the contents of this engine to the <a href="../qtcore/qdatastream.html">QDataStream</a> <i>out</i>. Returns <code>true</code> if the contents were written; otherwise returns <code>false</code>.</p> <p><a href="qiconengine.html">QIconEngine</a>'s default implementation always return false.</p> <!-- @@@write --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>