<?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[custom QLayout undeclared identifier &#x27;margin()&#x27;]]></title><description><![CDATA[<p dir="auto">I tried to copy the Qt code I wrote before, but I found that there is a definition missing</p>
<pre><code>int heightForWidth(int width) const override
{
        int height = (width - 2 * margin()) / m_aspectRatio + 2 * margin();
        return height;
}
</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/5109d2ac-df30-4fc5-874f-17b0f7c2c38c.png" alt="7bf83953-921f-4d23-8f75-a5f6e197c9b1-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/145793/custom-qlayout-undeclared-identifier-margin</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 02:02:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145793.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Jun 2023 14:48:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to custom QLayout undeclared identifier &#x27;margin()&#x27; on Thu, 15 Jun 2023 19:17:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You are trying to use code that was done with an older version of Qt. The margin method was already obsoleted with Qt 5 and was removed with Qt 6.</p>
<p dir="auto">You should use <a href="https://doc.qt.io/qt-6/qlayout.html#contentsMargins" target="_blank" rel="noopener noreferrer nofollow ugc">contentsMargins</a>.</p>
]]></description><link>https://forum.qt.io/post/761604</link><guid isPermaLink="true">https://forum.qt.io/post/761604</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 15 Jun 2023 19:17:12 GMT</pubDate></item><item><title><![CDATA[Reply to custom QLayout undeclared identifier &#x27;margin()&#x27; on Thu, 15 Jun 2023 15:00:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zeusfa">@<bdi>ZeusFa</bdi></a><br />
<code>QLayout</code> has a <code>heightForWidth()</code> (from <code>QLayoutItem</code>) which you can override, so I guess that is the method you are showing here.</p>
<p dir="auto">It has no <code>margin()</code> method anywhere, hence the code above won't compile.  Maybe you wrote another class.  Maybe you added a method.</p>
]]></description><link>https://forum.qt.io/post/761563</link><guid isPermaLink="true">https://forum.qt.io/post/761563</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 15 Jun 2023 15:00:44 GMT</pubDate></item></channel></rss>