<?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[Geometry looks invalid but calling isValid returns true.]]></title><description><![CDATA[<p dir="auto">In my parent window I pass <strong>this</strong> to the dialog constructor, I've checked the <strong>geometry</strong> of the parent window and for some reason it contains:</p>
<pre><code>x1    -2900
y1    490
x2    -2226
y2    961
</code></pre>
<p dir="auto">I've single stepped into the constructor where I have:</p>
<pre><code>QRect rctGeom(pParent-&gt;geometry());
rctGeom.setHeight(DataSets::mscuint16Height);
rctGeom.setWidth(DataSets::mscuint16Width);
if ( rctGeom.isValid() == true ) {
    setGeometry(rctGeom);
}
</code></pre>
<p dir="auto">After setting the height and width the geometry contains:</p>
<pre><code>x1    -2900
y1    410
x2    -2445
y2    949
</code></pre>
<p dir="auto"><strong>mscuint16Height</strong> contains 540, <strong>mscuint16Width</strong> contains 456.  I've single stepped onto the <strong>isValid</strong> call and it does return true which I find very odd given that both x1 and x2 are both negative.  After calling <strong>setGeometry</strong> I see in the console:</p>
<pre><code>QWindowsWindow::setGeometry: Unable to set geometry 480x540+-2900+410 on QWidgetWindow/'DataSetsClassWindow'. Resulting geometry:  486x540+-2900+410 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 480x482, maximum size: 16777215x16777215).
</code></pre>
<p dir="auto">Reading the documentation:<br />
<a href="https://doc.qt.io/qt-5/qrect.html#isValid" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qrect.html#isValid</a><br />
It is certainly doing what it says on the documentation, but personally I think the logic needs and should be changed to validate if the geometry results in a non-visible rectangle as this does.</p>
<p dir="auto">This is the logic it currently uses:</p>
<pre><code>A valid rectangle has a left() &lt;= right() and top() &lt;= bottom().
</code></pre>
<p dir="auto">I think it should be:  A valid rectangle should be:</p>
<pre><code> right() - left() &gt; 0 and top() - bottom() &gt; 0  and
 left() &lt;= right() and top() &lt;= bottom()
</code></pre>
]]></description><link>https://forum.qt.io/topic/127015/geometry-looks-invalid-but-calling-isvalid-returns-true</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 07:01:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/127015.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 May 2021 14:26:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Geometry looks invalid but calling isValid returns true. on Wed, 26 May 2021 16:34:03 GMT]]></title><description><![CDATA[<p dir="auto">Hi</p>
<blockquote>
<p dir="auto">single stepped into the constructor</p>
</blockquote>
<p dir="auto">You cannot trust size values when in a constructor as Qt will queue certain<br />
operation until actual shown.</p>
<p dir="auto">Try to do the same in showEvent and see.</p>
]]></description><link>https://forum.qt.io/post/661745</link><guid isPermaLink="true">https://forum.qt.io/post/661745</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 26 May 2021 16:34:03 GMT</pubDate></item><item><title><![CDATA[Reply to Geometry looks invalid but calling isValid returns true. on Wed, 26 May 2021 15:54:42 GMT]]></title><description><![CDATA[<p dir="auto">I don't see why a rectangle must have postive width or height...</p>
<p dir="auto"><a href="https://doc.qt.io/qt-5/qrect.html#normalized" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qrect.html#normalized</a></p>
]]></description><link>https://forum.qt.io/post/661738</link><guid isPermaLink="true">https://forum.qt.io/post/661738</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 26 May 2021 15:54:42 GMT</pubDate></item></channel></rss>