<?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[Problem with displaying % sign in a QString]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have tried various things to be able to display a % sign at the end of a string in a QLabel and have not been successful.<br />
Here are some of the things I have tried:</p>
<ol>
<li>Within the UI file:<br />
@<br />
&lt;widget class="QLabel" name="processMemUsedLabel" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;....     &lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text" &gt;<br />
&lt;string&gt;Used Mem %&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
@</li>
<li></li>
</ol>
<p dir="auto">@<br />
processMemUsedLabel-&gt;setTextFormat(Qt::RichText);<br />
QString testStr = QString("Used Mem") + QString(QChar('%'));<br />
processMemUsedLabel-&gt;setText(testStr);<br />
@</p>
<p dir="auto">Has anybody done this before? All that I want is a string to be displayed with a % sign at the end of the string.<br />
I would appreciate any inputs to make this work.</p>
<p dir="auto">Thanks!</p>
<p dir="auto">RS</p>
<p dir="auto"><em>[Edit: Added @ tags; mlong]</em></p>
]]></description><link>https://forum.qt.io/topic/16368/problem-with-displaying-sign-in-a-qstring</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 10:58:52 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16368.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 May 2012 21:25:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem with displaying % sign in a QString on Thu, 03 May 2012 21:09:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi RS, Just an FYI, use code tag while writing code in post for better readability. (right most symbol on post area)</p>
<p dir="auto">@//JustAnExample<br />
processMemUsedLabel-&gt;setTextFormat(Qt::RichText);<br />
QString testStr = QString(“Used Mem”) + QString(QChar(’%’));<br />
processMemUsedLabel-&gt;setText(testStr);@</p>
]]></description><link>https://forum.qt.io/post/137999</link><guid isPermaLink="true">https://forum.qt.io/post/137999</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 03 May 2012 21:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with displaying % sign in a QString on Tue, 01 May 2012 21:53:05 GMT]]></title><description><![CDATA[<p dir="auto">Never mind this issue.<br />
Both my above approaches work when I increased the width of the rectangle for the QLabel.<br />
I had specified 60 as the width and changing it to 80, made the % sign appear.<br />
Looks like the width of the QLabel rectangle and length of the string to be displayed have a certain formula!<br />
Thanks<br />
RS</p>
]]></description><link>https://forum.qt.io/post/137702</link><guid isPermaLink="true">https://forum.qt.io/post/137702</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 01 May 2012 21:53:05 GMT</pubDate></item></channel></rss>