<?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[QML how to center 4 labels in a rectangle]]></title><description><![CDATA[<p dir="auto">I am trying to center 4 symbols in a rectangle starting from the center.</p>
<p dir="auto">The rectangle code looks (simplified) like this</p>
<pre><code>Rectangle { id: userlogon_passwords; Layout.fillWidth: true; Layout.fillHeight: true; Layout.preferredHeight: 250; color: "yellow"
            RowLayout { anchors.centerIn: parent 
                spacing: 80
                UserPasswordField { index: 0; p_isSelected: userlogon.p_selectedField == 0 }
                UserPasswordField { index: 1; p_isSelected: userlogon.p_selectedField == 1 }
                UserPasswordField { index: 2; p_isSelected: userlogon.p_selectedField == 2 }
                UserPasswordField { index: 3; p_isSelected: userlogon.p_selectedField == 3 }
            }
        }
</code></pre>
<p dir="auto">UserPasswordField.qml looks like this</p>
<pre><code>Item {
    id: root
    property int index
    property bool p_isSelected
    property bool p_isTimerRunning
    property bool p_isRotated: p_isSelected &amp;&amp; p_isTimerRunning 
    property int p_value    

    Label {
        font.pixelSize: root.p_isRotated ? userlogon_passwords.height * 0.5 : userlogon_passwords.height * 0.4
        font.bold: root.p_isSelected
        color: configuration.getColor(root.p_isSelected ? Colors.PasswordEnabled : Colors.PasswordDisabled)
        text: root.p_isRotated ? root.p_value : "*"
        style: Text.Outline
        styleColor: "darkgray"
    }
}
</code></pre>
<p dir="auto">Result is this</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/341c2f2c-2428-4580-90be-88d28f6e9c1a.png" alt="stars.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The stars are shifted to the right, but should move further to the left. Is there a simple trick?</p>
]]></description><link>https://forum.qt.io/topic/142494/qml-how-to-center-4-labels-in-a-rectangle</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 23:44:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142494.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Jan 2023 14:45:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Mon, 30 Jan 2023 10:50:50 GMT]]></title><description><![CDATA[<p dir="auto">remove the outer Item in UserPasswordField.qml</p>
]]></description><link>https://forum.qt.io/post/745589</link><guid isPermaLink="true">https://forum.qt.io/post/745589</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Mon, 30 Jan 2023 10:50:50 GMT</pubDate></item><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Fri, 03 Feb 2023 09:01:15 GMT]]></title><description><![CDATA[<p dir="auto">You Item had a width and height of 0.<br />
Label has implicit width and height based on its content.</p>
]]></description><link>https://forum.qt.io/post/746117</link><guid isPermaLink="true">https://forum.qt.io/post/746117</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Fri, 03 Feb 2023 09:01:15 GMT</pubDate></item><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Fri, 03 Feb 2023 06:36:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/grecko">@<bdi>GrecKo</bdi></a> Sorry for late response. It works. Can you describe where the problem with the outer item is?</p>
]]></description><link>https://forum.qt.io/post/746101</link><guid isPermaLink="true">https://forum.qt.io/post/746101</guid><dc:creator><![CDATA[astoffregen]]></dc:creator><pubDate>Fri, 03 Feb 2023 06:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Mon, 30 Jan 2023 10:50:50 GMT]]></title><description><![CDATA[<p dir="auto">remove the outer Item in UserPasswordField.qml</p>
]]></description><link>https://forum.qt.io/post/745589</link><guid isPermaLink="true">https://forum.qt.io/post/745589</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Mon, 30 Jan 2023 10:50:50 GMT</pubDate></item><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Sat, 28 Jan 2023 20:56:41 GMT]]></title><description><![CDATA[<p dir="auto">You didnt set PasswordTextField width and height</p>
]]></description><link>https://forum.qt.io/post/745509</link><guid isPermaLink="true">https://forum.qt.io/post/745509</guid><dc:creator><![CDATA[freedbrt]]></dc:creator><pubDate>Sat, 28 Jan 2023 20:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to QML how to center 4 labels in a rectangle on Fri, 27 Jan 2023 14:49:23 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://forum.qt.io/topic/141934/calculate-width-of-qml-item/4">https://forum.qt.io/topic/141934/calculate-width-of-qml-item/4</a></p>
]]></description><link>https://forum.qt.io/post/745428</link><guid isPermaLink="true">https://forum.qt.io/post/745428</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Fri, 27 Jan 2023 14:49:23 GMT</pubDate></item></channel></rss>