<?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[[SOLVED] Error with setRect in QRect]]></title><description><![CDATA[<p dir="auto">Hello all!</p>
<p dir="auto">I have a QRect and when I try to setRect it return this error</p>
<p dir="auto">/QT/Projetos/VisaoFinanceira/fluxocaixawidget.cpp:174: error: member function 'setRect' not viable: 'this' argument has type 'const QRect', but function is not marked const<br />
<a href="http://fluxoRect.at" target="_blank" rel="noopener noreferrer nofollow ugc">fluxoRect.at</a>(i).setRect(7,7,7,7);</p>
<p dir="auto">Thanks.</p>
<p dir="auto">Here is the code:<br />
@<br />
QList&lt;QRect&gt; fluxoRect;</p>
<p dir="auto">fluxoRect.append(QRect(0,0,0,0));</p>
<p dir="auto"><a href="http://fluxoRect.at" target="_blank" rel="noopener noreferrer nofollow ugc">fluxoRect.at</a>(i).setRect(7,7,7,7);<br />
@</p>
]]></description><link>https://forum.qt.io/topic/42449/solved-error-with-setrect-in-qrect</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 12:39:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/42449.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jun 2014 20:02:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Error with setRect in QRect on Wed, 11 Jun 2014 20:43:16 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for the replies Saugglocke and SGaist</p>
<p dir="auto">It worked.</p>
<p dir="auto">@<br />
<a href="http://fluxoRect.at" target="_blank" rel="noopener noreferrer nofollow ugc">fluxoRect.at</a>(i).replace(QRect(7,7,7,7));<br />
@</p>
]]></description><link>https://forum.qt.io/post/231676</link><guid isPermaLink="true">https://forum.qt.io/post/231676</guid><dc:creator><![CDATA[guidupas]]></dc:creator><pubDate>Wed, 11 Jun 2014 20:43:16 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Error with setRect in QRect on Wed, 11 Jun 2014 20:38:10 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">at is a constant function so you can't modify it's returned value like that.</p>
<p dir="auto">Either use the value method or the [] operator.</p>
<p dir="auto">You can also take the rect modify it and replace the original value with the new value.</p>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/231675</link><guid isPermaLink="true">https://forum.qt.io/post/231675</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 11 Jun 2014 20:38:10 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Error with setRect in QRect on Wed, 11 Jun 2014 20:24:35 GMT]]></title><description><![CDATA[<p dir="auto">Hey,</p>
<p dir="auto">look at the definition of the at method:<br />
const T &amp; at(int i) const</p>
<p dir="auto">QList returns a const reference to your QRect, hence you're not allowed to alter it.</p>
<p dir="auto">You have to do something like this:<br />
@    QList&lt;QRect&gt; fluxoRect;</p>
<pre><code>fluxoRect.append(QRect(0,0,0,0));

QRect r = fluxoRect.takeAt(i);
r.setRect(7, 7, 7, 7);
fluxoRect.replace(i, r);@
</code></pre>
<p dir="auto">bb</p>
]]></description><link>https://forum.qt.io/post/231671</link><guid isPermaLink="true">https://forum.qt.io/post/231671</guid><dc:creator><![CDATA[Saugglocke]]></dc:creator><pubDate>Wed, 11 Jun 2014 20:24:35 GMT</pubDate></item></channel></rss>