<?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[Resize QPainter]]></title><description><![CDATA[<p dir="auto">Hi, i have a question. Suppose i have a MainWindow where, through paintEvent and QPainter, I draw a rectangle.<br />
I have noticed that if i resize the window, usinge the mouse, the rectangle doesn't change in size, it stays the same.<br />
How can i make the rectangle resize accordingly to the window?</p>
]]></description><link>https://forum.qt.io/topic/139201/resize-qpainter</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 11:30:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139201.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Sep 2022 21:26:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Resize QPainter on Fri, 09 Sep 2022 23:02:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/davide00">@<bdi>Davide00</bdi></a></p>
<pre><code>QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing,true);
 
QRect rec=contentsRect(); // takes margins into account if you set ones
painter.drawRect(rec);
</code></pre>
]]></description><link>https://forum.qt.io/post/728111</link><guid isPermaLink="true">https://forum.qt.io/post/728111</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Fri, 09 Sep 2022 23:02:43 GMT</pubDate></item><item><title><![CDATA[Reply to Resize QPainter on Fri, 09 Sep 2022 22:20:45 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">if i resize the window, usinge the mouse, the rectangle doesn't change in size, it stays the same</p>
</blockquote>
<p dir="auto">Why would it change on its own? You're drawing a rectangle by specifying the size in pixels, so you decide how big it is.</p>
<blockquote>
<p dir="auto">How can i make the rectangle resize accordingly to the window?</p>
</blockquote>
<p dir="auto">You can't make that rectangle resize. It's just drawn pixels. If you want a bigger rectangle you just draw a bigger rectangle. Widgets have a <code>size()</code>, <code>width()</code> and <code>height()</code> methods that give you their dimensions. If you want the rectangle to be, for example, half the width of the widget just pass <code>width()/2</code> as the width of the rectangle when you draw it.</p>
]]></description><link>https://forum.qt.io/post/728109</link><guid isPermaLink="true">https://forum.qt.io/post/728109</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Fri, 09 Sep 2022 22:20:45 GMT</pubDate></item></channel></rss>