<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qicon.cpp --> <title>QIcon Class | Qt GUI 5.12.2</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 >QIcon</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.2 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="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#related-non-members">Related Non-Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> <li class="level2"><a href="#making-classes-that-use-qicon">Making Classes that Use QIcon</a></li> <li class="level2"><a href="#high-dpi-icons">High DPI Icons</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QIcon Class</h1> <!-- $$$QIcon-brief --> <p>The <a href="qicon.html">QIcon</a> class provides scalable icons in different modes and states. <a href="#details">More...</a></p> <!-- @@@QIcon --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QIcon></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="qicon-members.html">List of all members, including inherited members</a></li> <li><a href="qicon-obsolete.html">Obsolete 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"> enum </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#Mode-enum">Mode</a></b> { Normal, Disabled, Active, Selected }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#State-enum">State</a></b> { Off, On }</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="qicon.html#QIcon">QIcon</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#QIcon-1">QIcon</a></b>(const QPixmap &<i>pixmap</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#QIcon-2">QIcon</a></b>(const QIcon &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#QIcon-3">QIcon</a></b>(QIcon &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#QIcon-4">QIcon</a></b>(const QString &<i>fileName</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#QIcon-5">QIcon</a></b>(QIconEngine *<i>engine</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#dtor.QIcon">~QIcon</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#actualSize">actualSize</a></b>(const QSize &<i>size</i>, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#actualSize-1">actualSize</a></b>(QWindow *<i>window</i>, const QSize &<i>size</i>, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#addFile">addFile</a></b>(const QString &<i>fileName</i>, const QSize &<i>size</i> = QSize(), QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#addPixmap">addPixmap</a></b>(const QPixmap &<i>pixmap</i>, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QList<QSize> </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#availableSizes">availableSizes</a></b>(QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#cacheKey">cacheKey</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#isMask">isMask</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#isNull">isNull</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#name">name</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#paint">paint</a></b>(QPainter *<i>painter</i>, const QRect &<i>rect</i>, Qt::Alignment <i>alignment</i> = Qt::AlignCenter, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#paint-1">paint</a></b>(QPainter *<i>painter</i>, int <i>x</i>, int <i>y</i>, int <i>w</i>, int <i>h</i>, Qt::Alignment <i>alignment</i> = Qt::AlignCenter, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#pixmap">pixmap</a></b>(const QSize &<i>size</i>, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#pixmap-1">pixmap</a></b>(int <i>w</i>, int <i>h</i>, QIcon::Mode <i>mode</i> = ..., QIcon::State <i>state</i> = ...) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#pixmap-2">pixmap</a></b>(int <i>extent</i>, QIcon::Mode <i>mode</i> = ..., QIcon::State <i>state</i> = ...) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#pixmap-3">pixmap</a></b>(QWindow *<i>window</i>, const QSize &<i>size</i>, QIcon::Mode <i>mode</i> = Normal, QIcon::State <i>state</i> = Off) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#setIsMask">setIsMask</a></b>(bool <i>isMask</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#swap">swap</a></b>(QIcon &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#operator-QVariant">operator QVariant</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QIcon &</td><td class="memItemRight bottomAlign"><b><a href="qicon.html#operator-eq">operator=</a></b>(const QIcon &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QIcon &</td><td class="memItemRight bottomAlign"><b><a href="qicon.html#operator-eq-1">operator=</a></b>(QIcon &&<i>other</i>)</td></tr> </table></div> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#fallbackSearchPaths">fallbackSearchPaths</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#fallbackThemeName">fallbackThemeName</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QIcon </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#fromTheme">fromTheme</a></b>(const QString &<i>name</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QIcon </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#fromTheme-1">fromTheme</a></b>(const QString &<i>name</i>, const QIcon &<i>fallback</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#hasThemeIcon">hasThemeIcon</a></b>(const QString &<i>name</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#setFallbackSearchPaths">setFallbackSearchPaths</a></b>(const QStringList &<i>paths</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#setFallbackThemeName">setFallbackThemeName</a></b>(const QString &<i>name</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#setThemeName">setThemeName</a></b>(const QString &<i>name</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#setThemeSearchPaths">setThemeSearchPaths</a></b>(const QStringList &<i>paths</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#themeName">themeName</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qicon.html#themeSearchPaths">themeSearchPaths</a></b>()</td></tr> </table></div> <a name="related-non-members"></a> <h2 id="related-non-members">Related Non-Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qicon.html#operator-lt-lt">operator<<</a></b>(QDataStream &<i>stream</i>, const QIcon &<i>icon</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qicon.html#operator-gt-gt">operator>></a></b>(QDataStream &<i>stream</i>, QIcon &<i>icon</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QIcon-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qicon.html">QIcon</a> class provides scalable icons in different modes and states.</p> <p>A <a href="qicon.html">QIcon</a> can generate smaller, larger, active, and disabled pixmaps from the set of pixmaps it is given. Such pixmaps are used by Qt widgets to show an icon representing a particular action.</p> <p>The simplest use of <a href="qicon.html">QIcon</a> is to create one from a <a href="qpixmap.html">QPixmap</a> file or resource, and then use it, allowing Qt to work out all the required icon styles and sizes. For example:</p> <pre class="cpp"> <span class="type"><a href="../qtwidgets/qtoolbutton.html">QToolButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qtoolbutton.html">QToolButton</a></span>; button<span class="operator">-</span><span class="operator">></span>setIcon(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span>(<span class="string">"open.xpm"</span>)); </pre> <p>To undo a <a href="qicon.html">QIcon</a>, simply set a null icon in its place:</p> <pre class="cpp"> button<span class="operator">-</span><span class="operator">></span>setIcon(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span>()); </pre> <p>Use the <a href="qimagereader.html#supportedImageFormats">QImageReader::supportedImageFormats</a>() and <a href="qimagewriter.html#supportedImageFormats">QImageWriter::supportedImageFormats</a>() functions to retrieve a complete list of the supported file formats.</p> <p>When you retrieve a pixmap using pixmap(<a href="../qtcore/qsize.html">QSize</a>, Mode, State), and no pixmap for this given size, mode and state has been added with <a href="qicon.html#addFile">addFile</a>() or <a href="qicon.html#addPixmap">addPixmap</a>(), then <a href="qicon.html">QIcon</a> will generate one on the fly. This pixmap generation happens in a <a href="qiconengine.html">QIconEngine</a>. The default engine scales pixmaps down if required, but never up, and it uses the current style to calculate a disabled appearance. By using custom icon engines, you can customize every aspect of generated icons. With <a href="qiconengineplugin.html">QIconEnginePlugin</a> it is possible to register different icon engines for different file suffixes, making it possible for third parties to provide additional icon engines to those included with Qt.</p> <p><b>Note: </b>Since Qt 4.2, an icon engine that supports SVG is included.</p><a name="making-classes-that-use-qicon"></a> <h3 >Making Classes that Use QIcon</h3> <p>If you write your own widgets that have an option to set a small pixmap, consider allowing a <a href="qicon.html">QIcon</a> to be set for that pixmap. The Qt class <a href="../qtwidgets/qtoolbutton.html">QToolButton</a> is an example of such a widget.</p> <p>Provide a method to set a <a href="qicon.html">QIcon</a>, and when you draw the icon, choose whichever pixmap is appropriate for the current state of your widget. For example:</p> <pre class="cpp"> <span class="type">void</span> MyWidget<span class="operator">::</span>drawIcon(<span class="type"><a href="qpainter.html">QPainter</a></span> <span class="operator">*</span>painter<span class="operator">,</span> <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> pos) { <span class="type"><a href="qpixmap.html">QPixmap</a></span> pixmap <span class="operator">=</span> icon<span class="operator">.</span>pixmap(<span class="type"><a href="../qtcore/qsize.html">QSize</a></span>(<span class="number">22</span><span class="operator">,</span> <span class="number">22</span>)<span class="operator">,</span> isEnabled() <span class="operator">?</span> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>Normal : <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>Disabled<span class="operator">,</span> isChecked() <span class="operator">?</span> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>On : <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>Off); painter<span class="operator">-</span><span class="operator">></span>drawPixmap(pos<span class="operator">,</span> pixmap); } </pre> <p>You might also make use of the <code>Active</code> mode, perhaps making your widget <code>Active</code> when the mouse is over the widget (see <a href="../qtwidgets/qwidget.html#enterEvent">QWidget::enterEvent</a>()), while the mouse is pressed pending the release that will activate the function, or when it is the currently selected item. If the widget can be toggled, the "On" mode might be used to draw a different icon.</p> <p class="centerAlign"><img src="images/icon.png" alt="QIcon" /></p><p><b>Note: </b><a href="qicon.html">QIcon</a> needs a <a href="qguiapplication.html">QGuiApplication</a> instance before the icon is created.</p><a name="high-dpi-icons"></a> <h3 >High DPI Icons</h3> <p>There are two ways that <a href="qicon.html">QIcon</a> supports high DPI icons: via <a href="qicon.html#addFile">addFile</a>() and <a href="qicon.html#fromTheme">fromTheme</a>().</p> <p><a href="qicon.html#addFile">addFile</a>() is useful if you have your own custom directory structure and do not need to use the <a href="https://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html">freedesktop.org Icon Theme Specification</a>. Icons created via this approach use Qt's <a href="qimagereader.html#high-resolution-versions-of-images">"@nx" high DPI syntax</a>.</p> <p>Using <a href="qicon.html#fromTheme">fromTheme</a>() is necessary if you plan on following the Icon Theme Specification. To make <a href="qicon.html">QIcon</a> use the high DPI version of an image, add an additional entry to the appropriate <code>index.theme</code> file:</p> <pre class="cpp plain"> [Icon Theme] Name=Test Comment=Test Theme Directories=32x32/actions,32x32@2/actions [32x32/actions] Size=32 Context=Actions Type=Fixed # High DPI version of the entry above. [32x32@2/actions] Size=32 Scale=2 Type=Fixed </pre> <p>Your icon theme directory would then look something like this:</p> <pre class="cpp plain"> ├── 32x32 │ └── actions │ └── appointment-new.png ├── 32x32@2 │ └── actions │ └── appointment-new.png └── index.theme </pre> </div> <p><b>See also </b><a href="../qtwidgets/guibooks.html#fowler">GUI Design Handbook: Iconic Label</a> and <a href="../qtwidgets/qtwidgets-widgets-icons-example.html">Icons Example</a>.</p> <!-- @@@QIcon --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$Mode$$$Normal$$$Disabled$$$Active$$$Selected --> <h3 class="fn" id="Mode-enum"><a name="Mode-enum"></a>enum QIcon::<span class="name">Mode</span></h3> <p>This enum type describes the mode for which a pixmap is intended to be used. The currently defined modes are:</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>QIcon::Normal</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available.</td></tr> <tr><td class="topAlign"><code>QIcon::Disabled</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Display the pixmap when the functionality represented by the icon is not available.</td></tr> <tr><td class="topAlign"><code>QIcon::Active</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">Display the pixmap when the functionality represented by the icon is available and the user is interacting with the icon, for example, moving the mouse over it or clicking it.</td></tr> <tr><td class="topAlign"><code>QIcon::Selected</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">Display the pixmap when the item represented by the icon is selected.</td></tr> </table></div> <!-- @@@Mode --> <!-- $$$State$$$On$$$Off --> <h3 class="fn" id="State-enum"><a name="State-enum"></a>enum QIcon::<span class="name">State</span></h3> <p>This enum describes the state for which a pixmap is intended to be used. The <i>state</i> can be:</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>QIcon::Off</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Display the pixmap when the widget is in an "off" state</td></tr> <tr><td class="topAlign"><code>QIcon::On</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">Display the pixmap when the widget is in an "on" state</td></tr> </table></div> <!-- @@@State --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QIcon[overload1]$$$QIcon --> <h3 class="fn" id="QIcon"><a name="QIcon"></a>QIcon::<span class="name">QIcon</span>()</h3> <p>Constructs a null icon.</p> <!-- @@@QIcon --> <!-- $$$QIcon$$$QIconconstQPixmap& --> <h3 class="fn" id="QIcon-1"><a name="QIcon-1"></a>QIcon::<span class="name">QIcon</span>(const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>)</h3> <p>Constructs an icon from a <i>pixmap</i>.</p> <!-- @@@QIcon --> <!-- $$$QIcon$$$QIconconstQIcon& --> <h3 class="fn" id="QIcon-2"><a name="QIcon-2"></a>QIcon::<span class="name">QIcon</span>(const <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>other</i>)</h3> <p>Constructs a copy of <i>other</i>. This is very fast.</p> <!-- @@@QIcon --> <!-- $$$QIcon$$$QIconQIcon&& --> <h3 class="fn" id="QIcon-3"><a name="QIcon-3"></a>QIcon::<span class="name">QIcon</span>(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &&<i>other</i>)</h3> <p>Move-constructs a <a href="qicon.html">QIcon</a> instance, making it point to the same object that <i>other</i> was pointing to.</p> <!-- @@@QIcon --> <!-- $$$QIcon$$$QIconconstQString& --> <h3 class="fn" id="QIcon-4"><a name="QIcon-4"></a>QIcon::<span class="name">QIcon</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>fileName</i>)</h3> <p>Constructs an icon from the file with the given <i>fileName</i>. The file will be loaded on demand.</p> <p>If <i>fileName</i> contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.</p> <p>The file name can refer to an actual file on disk or to one of the application's embedded resources. See the <a href="../qtcore/resources.html">Resource System</a> overview for details on how to embed images and other resource files in the application's executable.</p> <p>Use the <a href="qimagereader.html#supportedImageFormats">QImageReader::supportedImageFormats</a>() and <a href="qimagewriter.html#supportedImageFormats">QImageWriter::supportedImageFormats</a>() functions to retrieve a complete list of the supported file formats.</p> <!-- @@@QIcon --> <!-- $$$QIcon$$$QIconQIconEngine* --> <h3 class="fn" id="QIcon-5"><a name="QIcon-5"></a>QIcon::<span class="name">QIcon</span>(<span class="type"><a href="qiconengine.html">QIconEngine</a></span> *<i>engine</i>)</h3> <p>Creates an icon with a specific icon <i>engine</i>. The icon takes ownership of the engine.</p> <!-- @@@QIcon --> <!-- $$$~QIcon[overload1]$$$~QIcon --> <h3 class="fn" id="dtor.QIcon"><a name="dtor.QIcon"></a>QIcon::<span class="name">~QIcon</span>()</h3> <p>Destroys the icon.</p> <!-- @@@~QIcon --> <!-- $$$actualSize[overload1]$$$actualSizeconstQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="actualSize"><a name="actualSize"></a><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QIcon::<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> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Returns the actual size of the icon for the requested <i>size</i>, <i>mode</i>, and <i>state</i>. The result might be smaller than requested, but never larger. The returned size is in device-independent pixels (This is relevant for high-dpi pixmaps.)</p> <p><b>See also </b><a href="qicon.html#pixmap">pixmap</a>() and <a href="qicon.html#paint">paint</a>().</p> <!-- @@@actualSize --> <!-- $$$actualSize$$$actualSizeQWindow*constQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="actualSize-1"><a name="actualSize-1"></a><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QIcon::<span class="name">actualSize</span>(<span class="type"><a href="qwindow.html">QWindow</a></span> *<i>window</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> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Returns the actual size of the icon for the requested <i>window</i> <i>size</i>, <i>mode</i>, and <i>state</i>.</p> <p>The pixmap can be smaller than the requested size. The returned size is in device-independent pixels (This is relevant for high-dpi pixmaps.)</p> <p>This function was introduced in Qt 5.1.</p> <p><b>See also </b><a href="qicon.html#actualSize">actualSize</a>(), <a href="qicon.html#pixmap">pixmap</a>(), and <a href="qicon.html#paint">paint</a>().</p> <!-- @@@actualSize --> <!-- $$$addFile[overload1]$$$addFileconstQString&constQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="addFile"><a name="addFile"></a><span class="type">void</span> QIcon::<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> = QSize(), <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off)</h3> <p>Adds an image from the file with the given <i>fileName</i> to the icon, as a specialization for <i>size</i>, <i>mode</i> and <i>state</i>. The file will be loaded on demand. Note: custom icon engines are free to ignore additionally added pixmaps.</p> <p>If <i>fileName</i> contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.</p> <p>The file name can refer to an actual file on disk or to one of the application's embedded resources. See the <a href="../qtcore/resources.html">Resource System</a> overview for details on how to embed images and other resource files in the application's executable.</p> <p>Use the <a href="qimagereader.html#supportedImageFormats">QImageReader::supportedImageFormats</a>() and <a href="qimagewriter.html#supportedImageFormats">QImageWriter::supportedImageFormats</a>() functions to retrieve a complete list of the supported file formats.</p> <p>If a high resolution version of the image exists (identified by the suffix <code>@2x</code> on the base name), it is automatically loaded and added with the <i>device pixel ratio</i> set to a value of 2. This can be disabled by setting the environment variable <code>QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING</code> (see <a href="qimagereader.html">QImageReader</a>).</p> <p><b>Note: </b>When you add a non-empty filename to a <a href="qicon.html">QIcon</a>, the icon becomes non-null, even if the file doesn't exist or points to a corrupt file.</p><p><b>See also </b><a href="qicon.html#addPixmap">addPixmap</a>() and <a href="qpixmap.html#devicePixelRatio">QPixmap::devicePixelRatio</a>().</p> <!-- @@@addFile --> <!-- $$$addPixmap[overload1]$$$addPixmapconstQPixmap&QIcon::ModeQIcon::State --> <h3 class="fn" id="addPixmap"><a name="addPixmap"></a><span class="type">void</span> QIcon::<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> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off)</h3> <p>Adds <i>pixmap</i> to the icon, as a specialization for <i>mode</i> and <i>state</i>.</p> <p>Custom icon engines are free to ignore additionally added pixmaps.</p> <p><b>See also </b><a href="qicon.html#addFile">addFile</a>().</p> <!-- @@@addPixmap --> <!-- $$$availableSizes[overload1]$$$availableSizesQIcon::ModeQIcon::State --> <h3 class="fn" id="availableSizes"><a name="availableSizes"></a><span class="type">QList</span><<span class="type"><a href="../qtcore/qsize.html">QSize</a></span>> QIcon::<span class="name">availableSizes</span>(<span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Returns a list of available icon sizes for the specified <i>mode</i> and <i>state</i>.</p> <p>This function was introduced in Qt 4.5.</p> <!-- @@@availableSizes --> <!-- $$$cacheKey[overload1]$$$cacheKey --> <h3 class="fn" id="cacheKey"><a name="cacheKey"></a><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QIcon::<span class="name">cacheKey</span>() const</h3> <p>Returns a number that identifies the contents of this <a href="qicon.html">QIcon</a> object. Distinct <a href="qicon.html">QIcon</a> objects can have the same key if they refer to the same contents.</p> <p>The cacheKey() will change when the icon is altered via <a href="qicon.html#addPixmap">addPixmap</a>() or <a href="qicon.html#addFile">addFile</a>().</p> <p>Cache keys are mostly useful in conjunction with caching.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also </b><a href="qpixmap.html#cacheKey">QPixmap::cacheKey</a>().</p> <!-- @@@cacheKey --> <!-- $$$fallbackSearchPaths[overload1]$$$fallbackSearchPaths --> <h3 class="fn" id="fallbackSearchPaths"><a name="fallbackSearchPaths"></a><code>[static] </code><span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> QIcon::<span class="name">fallbackSearchPaths</span>()</h3> <p>Returns the fallback search paths for icons.</p> <p>The default value will depend on the platform.</p> <p>This function was introduced in Qt 5.11.</p> <p><b>See also </b><a href="qicon.html#setFallbackSearchPaths">setFallbackSearchPaths</a>() and <a href="qicon.html#themeSearchPaths">themeSearchPaths</a>().</p> <!-- @@@fallbackSearchPaths --> <!-- $$$fallbackThemeName[overload1]$$$fallbackThemeName --> <h3 class="fn" id="fallbackThemeName"><a name="fallbackThemeName"></a><code>[static] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QIcon::<span class="name">fallbackThemeName</span>()</h3> <p>Returns the name of the fallback icon theme.</p> <p>On X11, if not set, the fallback icon theme depends on your desktop settings. On other platforms it is not set by default.</p> <p>This function was introduced in Qt 5.12.</p> <p><b>See also </b><a href="qicon.html#setFallbackThemeName">setFallbackThemeName</a>() and <a href="qicon.html#themeName">themeName</a>().</p> <!-- @@@fallbackThemeName --> <!-- $$$fromTheme[overload1]$$$fromThemeconstQString& --> <h3 class="fn" id="fromTheme"><a name="fromTheme"></a><code>[static] </code><span class="type"><a href="qicon.html#QIcon">QIcon</a></span> QIcon::<span class="name">fromTheme</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>name</i>)</h3> <p>Returns the <a href="qicon.html">QIcon</a> corresponding to <i>name</i> in the current icon theme.</p> <p>The latest version of the freedesktop icon specification and naming specification can be obtained here:</p> <ul> <li><a href="http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html">http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html</a></li> <li><a href="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html</a></li> </ul> <p>To fetch an icon from the current icon theme:</p> <pre class="cpp"> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> undoicon <span class="operator">=</span> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>fromTheme(<span class="string">"edit-undo"</span>); </pre> <p><b>Note: </b>By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your <a href="qicon.html#themeSearchPaths">themeSearchPaths</a>() and set the appropriate <a href="qicon.html#themeName">themeName</a>().</p><p><b>Note: </b>Qt will make use of GTK's icon-theme.cache if present to speed up the lookup. These caches can be generated using gtk-update-icon-cache: <a href="https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html">https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html</a>.</p><p><b>Note: </b>If an icon can't be found in the current theme, then it will be searched in <a href="qicon.html#fallbackSearchPaths">fallbackSearchPaths</a>() as an unthemed icon.</p><p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#themeName">themeName</a>(), <a href="qicon.html#setThemeName">setThemeName</a>(), <a href="qicon.html#themeSearchPaths">themeSearchPaths</a>(), and <a href="qicon.html#fallbackSearchPaths">fallbackSearchPaths</a>().</p> <!-- @@@fromTheme --> <!-- $$$fromTheme$$$fromThemeconstQString&constQIcon& --> <h3 class="fn" id="fromTheme-1"><a name="fromTheme-1"></a><code>[static] </code><span class="type"><a href="qicon.html#QIcon">QIcon</a></span> QIcon::<span class="name">fromTheme</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>name</i>, const <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>fallback</i>)</h3> <p>This is an overloaded function.</p> <p>Returns the <a href="qicon.html">QIcon</a> corresponding to <i>name</i> in the current icon theme. If no such icon is found in the current theme <i>fallback</i> is returned instead.</p> <p>If you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:</p> <pre class="cpp"> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> undoicon <span class="operator">=</span> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>fromTheme(<span class="string">"edit-undo"</span><span class="operator">,</span> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span>(<span class="string">":/undo.png"</span>)); </pre> <!-- @@@fromTheme --> <!-- $$$hasThemeIcon[overload1]$$$hasThemeIconconstQString& --> <h3 class="fn" id="hasThemeIcon"><a name="hasThemeIcon"></a><code>[static] </code><span class="type">bool</span> QIcon::<span class="name">hasThemeIcon</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>name</i>)</h3> <p>Returns <code>true</code> if there is an icon available for <i>name</i> in the current icon theme, otherwise returns <code>false</code>.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#themeSearchPaths">themeSearchPaths</a>(), <a href="qicon.html#fromTheme">fromTheme</a>(), and <a href="qicon.html#setThemeName">setThemeName</a>().</p> <!-- @@@hasThemeIcon --> <!-- $$$isMask[overload1]$$$isMask --> <h3 class="fn" id="isMask"><a name="isMask"></a><span class="type">bool</span> QIcon::<span class="name">isMask</span>() const</h3> <p>Returns <code>true</code> if this icon has been marked as a mask image. Certain platforms render mask icons differently (for example, menu icons on macOS).</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qicon.html#setIsMask">setIsMask</a>().</p> <!-- @@@isMask --> <!-- $$$isNull[overload1]$$$isNull --> <h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QIcon::<span class="name">isNull</span>() const</h3> <p>Returns <code>true</code> if the icon is empty; otherwise returns <code>false</code>.</p> <p>An icon is empty if it has neither a pixmap nor a filename.</p> <p>Note: Even a non-null icon might not be able to create valid pixmaps, eg. if the file does not exist or cannot be read.</p> <!-- @@@isNull --> <!-- $$$name[overload1]$$$name --> <h3 class="fn" id="name"><a name="name"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QIcon::<span class="name">name</span>() const</h3> <p>Returns the name used to create the icon, if available.</p> <p>Depending on the way the icon was created, it may have an associated name. This is the case for icons created with <a href="qicon.html#fromTheme">fromTheme</a>() or icons using a <a href="qiconengine.html">QIconEngine</a> which supports the <a href="qiconengine.html#IconEngineHook-enum">QIconEngine::IconNameHook</a>.</p> <p>This function was introduced in Qt 4.7.</p> <p><b>See also </b><a href="qicon.html#fromTheme">fromTheme</a>() and <a href="qiconengine.html">QIconEngine</a>.</p> <!-- @@@name --> <!-- $$$paint[overload1]$$$paintQPainter*constQRect&Qt::AlignmentQIcon::ModeQIcon::State --> <h3 class="fn" id="paint"><a name="paint"></a><span class="type">void</span> QIcon::<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="../qtcore/qt.html#AlignmentFlag-enum">Qt::Alignment</a></span> <i>alignment</i> = Qt::AlignCenter, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Uses the <i>painter</i> to paint the icon with specified <i>alignment</i>, required <i>mode</i>, and <i>state</i> into the rectangle <i>rect</i>.</p> <p><b>See also </b><a href="qicon.html#actualSize">actualSize</a>() and <a href="qicon.html#pixmap">pixmap</a>().</p> <!-- @@@paint --> <!-- $$$paint$$$paintQPainter*intintintintQt::AlignmentQIcon::ModeQIcon::State --> <h3 class="fn" id="paint-1"><a name="paint-1"></a><span class="type">void</span> QIcon::<span class="name">paint</span>(<span class="type"><a href="qpainter.html">QPainter</a></span> *<i>painter</i>, <span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i>, <span class="type">int</span> <i>w</i>, <span class="type">int</span> <i>h</i>, <span class="type"><a href="../qtcore/qt.html#AlignmentFlag-enum">Qt::Alignment</a></span> <i>alignment</i> = Qt::AlignCenter, <span class="type"><a href="qicon.html#Mode-enum">QIcon::Mode</a></span> <i>mode</i> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>This is an overloaded function.</p> <p>Paints the icon into the rectangle <a href="../qtcore/qrect.html">QRect</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>).</p> <!-- @@@paint --> <!-- $$$pixmap[overload1]$$$pixmapconstQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="pixmap"><a name="pixmap"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIcon::<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> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Returns a pixmap with the requested <i>size</i>, <i>mode</i>, and <i>state</i>, generating one if necessary. The pixmap might be smaller than requested, but never larger.</p> <p>Setting the <a href="../qtcore/qt.html#ApplicationAttribute-enum">Qt::AA_UseHighDpiPixmaps</a> application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.</p> <p><b>See also </b><a href="qicon.html#actualSize">actualSize</a>() and <a href="qicon.html#paint">paint</a>().</p> <!-- @@@pixmap --> <!-- $$$pixmap$$$pixmapintintQIcon::ModeQIcon::State --> <h3 class="fn" id="pixmap-1"><a name="pixmap-1"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIcon::<span class="name">pixmap</span>(<span class="type">int</span> <i>w</i>, <span class="type">int</span> <i>h</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> = ...) const</h3> <p>This is an overloaded function.</p> <p>Returns a pixmap of size <a href="../qtcore/qsize.html">QSize</a>(<i>w</i>, <i>h</i>). The pixmap might be smaller than requested, but never larger.</p> <p>Setting the <a href="../qtcore/qt.html#ApplicationAttribute-enum">Qt::AA_UseHighDpiPixmaps</a> application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.</p> <!-- @@@pixmap --> <!-- $$$pixmap$$$pixmapintQIcon::ModeQIcon::State --> <h3 class="fn" id="pixmap-2"><a name="pixmap-2"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIcon::<span class="name">pixmap</span>(<span class="type">int</span> <i>extent</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> = ...) const</h3> <p>This is an overloaded function.</p> <p>Returns a pixmap of size <a href="../qtcore/qsize.html">QSize</a>(<i>extent</i>, <i>extent</i>). The pixmap might be smaller than requested, but never larger.</p> <p>Setting the <a href="../qtcore/qt.html#ApplicationAttribute-enum">Qt::AA_UseHighDpiPixmaps</a> application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.</p> <!-- @@@pixmap --> <!-- $$$pixmap$$$pixmapQWindow*constQSize&QIcon::ModeQIcon::State --> <h3 class="fn" id="pixmap-3"><a name="pixmap-3"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QIcon::<span class="name">pixmap</span>(<span class="type"><a href="qwindow.html">QWindow</a></span> *<i>window</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> = Normal, <span class="type"><a href="qicon.html#State-enum">QIcon::State</a></span> <i>state</i> = Off) const</h3> <p>Returns a pixmap with the requested <i>window</i> <i>size</i>, <i>mode</i>, and <i>state</i>, generating one if necessary.</p> <p>The pixmap can be smaller than the requested size. If <i>window</i> is on a high-dpi display the pixmap can be larger. In that case it will have a devicePixelRatio larger than 1.</p> <p>This function was introduced in Qt 5.1.</p> <p><b>See also </b><a href="qicon.html#actualSize">actualSize</a>() and <a href="qicon.html#paint">paint</a>().</p> <!-- @@@pixmap --> <!-- $$$setFallbackSearchPaths[overload1]$$$setFallbackSearchPathsconstQStringList& --> <h3 class="fn" id="setFallbackSearchPaths"><a name="setFallbackSearchPaths"></a><code>[static] </code><span class="type">void</span> QIcon::<span class="name">setFallbackSearchPaths</span>(const <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> &<i>paths</i>)</h3> <p>Sets the fallback search paths for icons to <i>paths</i>.</p> <p><b>Note: </b>To add some path without replacing existing ones:</p><pre class="cpp"> <span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>setFallbackSearchPaths(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span><span class="operator">::</span>fallbackSearchPaths() <span class="operator"><</span><span class="operator"><</span> <span class="string">"my/search/path"</span>); </pre> <p>This function was introduced in Qt 5.11.</p> <p><b>See also </b><a href="qicon.html#fallbackSearchPaths">fallbackSearchPaths</a>() and <a href="qicon.html#setThemeSearchPaths">setThemeSearchPaths</a>().</p> <!-- @@@setFallbackSearchPaths --> <!-- $$$setFallbackThemeName[overload1]$$$setFallbackThemeNameconstQString& --> <h3 class="fn" id="setFallbackThemeName"><a name="setFallbackThemeName"></a><code>[static] </code><span class="type">void</span> QIcon::<span class="name">setFallbackThemeName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>name</i>)</h3> <p>Sets the fallback icon theme to <i>name</i>.</p> <p>The <i>name</i> should correspond to a directory name in the themeSearchPath() containing an index.theme file describing its contents.</p> <p>This function was introduced in Qt 5.12.</p> <p><b>See also </b><a href="qicon.html#fallbackThemeName">fallbackThemeName</a>(), <a href="qicon.html#themeSearchPaths">themeSearchPaths</a>(), and <a href="qicon.html#themeName">themeName</a>().</p> <!-- @@@setFallbackThemeName --> <!-- $$$setIsMask[overload1]$$$setIsMaskbool --> <h3 class="fn" id="setIsMask"><a name="setIsMask"></a><span class="type">void</span> QIcon::<span class="name">setIsMask</span>(<span class="type">bool</span> <i>isMask</i>)</h3> <p>Indicate that this icon is a mask image(boolean <i>isMask</i>), and hence can potentially be modified based on where it's displayed.</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qicon.html#isMask">isMask</a>().</p> <!-- @@@setIsMask --> <!-- $$$setThemeName[overload1]$$$setThemeNameconstQString& --> <h3 class="fn" id="setThemeName"><a name="setThemeName"></a><code>[static] </code><span class="type">void</span> QIcon::<span class="name">setThemeName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>name</i>)</h3> <p>Sets the current icon theme to <i>name</i>.</p> <p>The <i>name</i> should correspond to a directory name in the themeSearchPath() containing an index.theme file describing its contents.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#themeSearchPaths">themeSearchPaths</a>() and <a href="qicon.html#themeName">themeName</a>().</p> <!-- @@@setThemeName --> <!-- $$$setThemeSearchPaths[overload1]$$$setThemeSearchPathsconstQStringList& --> <h3 class="fn" id="setThemeSearchPaths"><a name="setThemeSearchPaths"></a><code>[static] </code><span class="type">void</span> QIcon::<span class="name">setThemeSearchPaths</span>(const <span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> &<i>paths</i>)</h3> <p>Sets the search paths for icon themes to <i>paths</i>.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#themeSearchPaths">themeSearchPaths</a>(), <a href="qicon.html#fromTheme">fromTheme</a>(), and <a href="qicon.html#setThemeName">setThemeName</a>().</p> <!-- @@@setThemeSearchPaths --> <!-- $$$swap[overload1]$$$swapQIcon& --> <h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QIcon::<span class="name">swap</span>(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>other</i>)</h3> <p>Swaps icon <i>other</i> with this icon. This operation is very fast and never fails.</p> <p>This function was introduced in Qt 4.8.</p> <!-- @@@swap --> <!-- $$$themeName[overload1]$$$themeName --> <h3 class="fn" id="themeName"><a name="themeName"></a><code>[static] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QIcon::<span class="name">themeName</span>()</h3> <p>Returns the name of the current icon theme.</p> <p>On X11, the current icon theme depends on your desktop settings. On other platforms it is not set by default.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#setThemeName">setThemeName</a>(), <a href="qicon.html#themeSearchPaths">themeSearchPaths</a>(), <a href="qicon.html#fromTheme">fromTheme</a>(), and <a href="qicon.html#hasThemeIcon">hasThemeIcon</a>().</p> <!-- @@@themeName --> <!-- $$$themeSearchPaths[overload1]$$$themeSearchPaths --> <h3 class="fn" id="themeSearchPaths"><a name="themeSearchPaths"></a><code>[static] </code><span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> QIcon::<span class="name">themeSearchPaths</span>()</h3> <p>Returns the search paths for icon themes.</p> <p>The default value will depend on the platform:</p> <p>On X11, the search path will use the XDG_DATA_DIRS environment variable if available.</p> <p>By default all platforms will have the resource directory <code>:\icons</code> as a fallback. You can use "rcc -project" to generate a resource file from your icon theme.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also </b><a href="qicon.html#setThemeSearchPaths">setThemeSearchPaths</a>(), <a href="qicon.html#fromTheme">fromTheme</a>(), and <a href="qicon.html#setThemeName">setThemeName</a>().</p> <!-- @@@themeSearchPaths --> <!-- $$$operator QVariant[overload1]$$$operator QVariant --> <h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QIcon::<span class="name">operator QVariant</span>() const</h3> <p>Returns the icon as a <a href="../qtcore/qvariant.html">QVariant</a>.</p> <!-- @@@operator QVariant --> <!-- $$$operator=[overload1]$$$operator=constQIcon& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &QIcon::<span class="name">operator=</span>(const <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>other</i>)</h3> <p>Assigns the <i>other</i> icon to this icon and returns a reference to this icon.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=QIcon&& --> <h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &QIcon::<span class="name">operator=</span>(<span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &&<i>other</i>)</h3> <p>Move-assigns <i>other</i> to this <a href="qicon.html">QIcon</a> instance.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@operator= --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQIcon& --> <h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<span class="name">operator<<</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>stream</i>, const <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>icon</i>)</h3> <p>Writes the given <i>icon</i> to the given <i>stream</i> as a PNG image. If the icon contains more than one image, all images will be written to the stream. Note that writing the stream to a file will not produce a valid image file.</p> <p>This function was introduced in Qt 4.2.</p> <!-- @@@operator<< --> <!-- $$$operator>>[overload1]$$$operator>>QDataStream&QIcon& --> <h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<span class="name">operator>></span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>stream</i>, <span class="type"><a href="qicon.html#QIcon">QIcon</a></span> &<i>icon</i>)</h3> <p>Reads an image, or a set of images, from the given <i>stream</i> into the given <i>icon</i>.</p> <p>This function was introduced in Qt 4.2.</p> <!-- @@@operator>> --> </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>