<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Specifying different iconsets for the same widget]]></title><description><![CDATA[<p dir="auto">@   &lt;widget class="LedButton" name="m_Standby_btn1" &gt;</p>
<pre><code> &lt;property name="icon" &gt;

   &lt;iconset resource="VSMgui.qrc"&gt;:/images/images/whiteCircle_nt.png&lt;/iconset&gt;

 &lt;/property&gt;

    &lt;property name="text" &gt;

   &lt;string&gt;Standby--&lt;/string&gt;

 &lt;/property&gt;

     &lt;property name="visible"&gt; &lt;bool&gt;false--&lt;/bool&gt; &lt;/property&gt;
</code></pre>
<p dir="auto">&lt;/widget&gt;<br />
@<br />
I want to be able to display a different icon dynamically if this button is selected.<br />
So, I am trying to create a button with 2 png files (such that any one can be used at any point of time)&gt;<br />
Is it possible to specify this in a UI file?</p>
<p dir="auto">Or would I have to create two buttons each with a different png file?</p>
<p dir="auto">Thanks</p>
<p dir="auto">RS</p>
]]></description><link>https://forum.qt.io/topic/16369/specifying-different-iconsets-for-the-same-widget</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 12:22:36 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16369.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 May 2012 21:31:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 09 May 2012 16:57:47 GMT]]></title><description><![CDATA[<p dir="auto">I tried qxoz's suggestion of adding the &lt;normaloff&gt; and &lt;selectedon&gt; tags but with this, no icon is generated. Here's how my UI file looks like: I even added a &lt;normalon&gt; tag just in case and that did not help either....</p>
<p dir="auto">@@<br />
&lt;widget class="LedButton" name="m_Standby_btn" &gt;<br />
&lt;property name="icon"&gt;<br />
&lt;iconset resource="VSMgui.qrc"&gt;<br />
&lt;normalon&gt;:/images/images/whiteCircle_nt.png&lt;/normalon&gt;<br />
&lt;normaloff&gt;:/images/images/whiteCircle_nt.png&lt;/normaloff&gt;<br />
&lt;selectedon&gt;:/images/images/blueCircle_nt.png&lt;/selectedon&gt;<br />
&lt;/iconset&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text" &gt;<br />
&lt;string&gt;Standby&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;property name="visible"&gt; &lt;bool&gt;true&lt;/bool&gt; &lt;/property&gt;<br />
&lt;/widget&gt;<br />
@@</p>
]]></description><link>https://forum.qt.io/post/138503</link><guid isPermaLink="true">https://forum.qt.io/post/138503</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 09 May 2012 16:57:47 GMT</pubDate></item><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 09 May 2012 16:56:04 GMT]]></title><description><![CDATA[<p dir="auto">I tried qxoz's suggestion of adding the &lt;normaloff&gt; and &lt;selectedon&gt; tags but with this, no icon is generated. Here's how my UI file looks like: I even added a &lt;normalon&gt; tag just in case and that did not help either....</p>
<p dir="auto">@@<br />
&lt;widget class="LedButton" name="m_Standby_btn" &gt;<br />
&lt;property name="icon"&gt;<br />
&lt;iconset resource="VSMgui.qrc"&gt;<br />
&lt;normalon&gt;:/images/images/whiteCircle_nt.png&lt;/normalon&gt;<br />
&lt;normaloff&gt;:/images/images/whiteCircle_nt.png&lt;/normaloff&gt;<br />
&lt;selectedon&gt;:/images/images/blueCircle_nt.png&lt;/selectedon&gt;<br />
&lt;/iconset&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text" &gt;<br />
&lt;string&gt;Standby&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;property name="visible"&gt; &lt;bool&gt;true&lt;/bool&gt; &lt;/property&gt;<br />
&lt;/widget&gt;<br />
@@</p>
]]></description><link>https://forum.qt.io/post/138502</link><guid isPermaLink="true">https://forum.qt.io/post/138502</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 09 May 2012 16:56:04 GMT</pubDate></item><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 02 May 2012 15:59:46 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the inputs.</p>
<p dir="auto">I had tried the setIcon() solution and it works most of the time but I keep seeing the following 2 crashes once in a while and so I have decided to implement this dynamic Icon thing in the UI file now to avoid the crash.</p>
<p dir="auto">This is how I had used the functions<br />
@<br />
// remove explicit reference to QPixmap to avoid the crash that happens<br />
// sporadically<br />
if (bSelected) {<br />
setIcon(QIcon(QString::fromUtf8(":/images/images/whiteCircle_nt.png")));<br />
} else {<br />
setIcon(QIcon(QString::fromUtf8(":/images/images/blueCircle_nt.png")));<br />
}<br />
}<br />
@<br />
Please let me know if any of you have seen such intermittent crashes wen using setIcon() function.<br />
@<br />
Crash #1 Backtrace:<br />
#0  0x0f89a2ac in QX11Info::visual () from /usr/lib/libQtGui.so.4<br />
#1  0x0f8d192c in QPixmap::toImage () from /usr/lib/libQtGui.so.4<br />
#2  0x0fa58918 in QCommonStyle::generatedIconPixmap () from /usr/lib/libQtGui.so.4<br />
#3  0x0f8a3108 in QIcon::QIcon () from /usr/lib/libQtGui.so.4<br />
#4  0x0f8a08d8 in QIcon::pixmap () from /usr/lib/libQtGui.so.4<br />
@<br />
OR<br />
@<br />
Crash #2 Backtrace:<br />
#0  0x0f2f9e00 in memcpy () from /lib/tls/libc.so.6<br />
#1  0x10166b90 in ?? ()<br />
#2  0x0f521160 in QVectorData::malloc () from /usr/lib/libQtCore.so.4<br />
#3  0x0f937e58 in operator&lt;&lt; () from /usr/lib/libQtGui.so.4<br />
#4  0x0f96c170 in QRegion::copy () from /usr/lib/libQtGui.so.4<br />
#5  0x0f96a178 in QRegion::QRegion () from /usr/lib/libQtGui.so.4<br />
#6  0x0f96a87c in QRegion::QRegion () from /usr/lib/libQtGui.so.4<br />
#7  0x0f96be30 in QRegion::unite () from /usr/lib/libQtGui.so.4<br />
#8  0x0f9366ec in QRegion::operator+ () from /usr/lib/libQtGui.so.4<br />
#9  0x0f936740 in QRegion::operator+= () from /usr/lib/libQtGui.so.4<br />
#10 0x0f96e7a4 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4<br />
#11 0x0f96f734 in QWidget::update () from /usr/lib/libQtGui.so.4<br />
#12 0x0f96f7b8 in QWidget::update () from /usr/lib/libQtGui.so.4<br />
#13 0x0f96f840 in QWidget::update () from /usr/lib/libQtGui.so.4<br />
#14 0x0fad686c in QAbstractButton::setIcon () from /usr/lib/libQtGui.so.4<br />
@</p>
<p dir="auto"><em>Edit: Please use @ signs around code sections; Andre</em></p>
]]></description><link>https://forum.qt.io/post/137777</link><guid isPermaLink="true">https://forum.qt.io/post/137777</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 02 May 2012 15:59:46 GMT</pubDate></item><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 02 May 2012 11:44:26 GMT]]></title><description><![CDATA[<p dir="auto">I'd use a style sheet for that.</p>
]]></description><link>https://forum.qt.io/post/137753</link><guid isPermaLink="true">https://forum.qt.io/post/137753</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 02 May 2012 11:44:26 GMT</pubDate></item><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 02 May 2012 11:29:55 GMT]]></title><description><![CDATA[<p dir="auto">Sorry i don't  understood you, at first time.<br />
In UI file you can specify this in following way:<br />
@&lt;property name="icon"&gt;<br />
&lt;iconset resource="res.qrc"&gt;<br />
&lt;normaloff&gt;:/icon/Connect.png&lt;/normaloff&gt;<br />
&lt;selectedon&gt;:/icon/Disconnect.png&lt;/selectedon&gt;:/icon/Connect.png&lt;/iconset&gt;<br />
&lt;/property&gt;@</p>
<p dir="auto">or with QtCreator's  interface in widgets property window(icon-&gt;Normal, Active, Selected,Disabled).</p>
]]></description><link>https://forum.qt.io/post/137754</link><guid isPermaLink="true">https://forum.qt.io/post/137754</guid><dc:creator><![CDATA[qxoz]]></dc:creator><pubDate>Wed, 02 May 2012 11:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to Specifying different iconsets for the same widget on Wed, 02 May 2012 11:12:36 GMT]]></title><description><![CDATA[<p dir="auto">You can use<br />
@setIcon(QIcon(":/icon/SomeIcon.png"));@</p>
<p dir="auto">and change icon by some SIGNAL</p>
<p dir="auto">@setIcon(QIcon(":/icon/SomeOtherIcon.png"));@</p>
]]></description><link>https://forum.qt.io/post/137750</link><guid isPermaLink="true">https://forum.qt.io/post/137750</guid><dc:creator><![CDATA[qxoz]]></dc:creator><pubDate>Wed, 02 May 2012 11:12:36 GMT</pubDate></item></channel></rss>