<?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[RoundButton not taking correct height setting]]></title><description><![CDATA[<p dir="auto">Hi all -</p>
<p dir="auto">Minimal code:</p>
<pre><code>import QtQuick
import QtQuick.Controls

ApplicationWindow {
    id: mainWindow

    visible: true
    width: 800
    height: 480

    menuBar: Rectangle {
        id: navBar
        height: 56
        width: mainWindow.width
        color: 'lightgray'

        RoundButton {
            id: testButton
            text: testButton.height
            anchors.centerIn: parent
            height: navBar.height / 2
            radius: height / 2
        }
    }
}
</code></pre>
<p dir="auto">Can someone explain to me why the height of the RoundButton is correct on Windows:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/f5e707a6-d01c-4054-86ce-2c86e6281c46.PNG" alt="windows.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">But not on Android:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/e0c3079a-d909-4c7c-b4fb-2a652c232432.PNG" alt="android.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">I realize there are style differences at play between the platforms, but...shouldn't a height setting be correctly observed regardless?</p>
<p dir="auto">Qt 6.4.2. Android emulator, but verified on some cheap Galaxy tablet.</p>
<p dir="auto">Thanks...</p>
]]></description><link>https://forum.qt.io/topic/142263/roundbutton-not-taking-correct-height-setting</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 22:02:11 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142263.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Jan 2023 00:29:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Sat, 28 Jan 2023 15:04:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> interesting...the problem appears to be specific to the Material style. Applying a background makes it better (though it still doesn't look quite right).</p>
<p dir="auto">EDIT: I also discovered that the Material style isn't displaying the icon correctly. I'm going to close this topic and open a new one.</p>
]]></description><link>https://forum.qt.io/post/745337</link><guid isPermaLink="true">https://forum.qt.io/post/745337</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Sat, 28 Jan 2023 15:04:49 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 22:01:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> Qt 5.15.2 on Ubuntu 18. Maybe try also<br />
implicitHeight: 60</p>
]]></description><link>https://forum.qt.io/post/745336</link><guid isPermaLink="true">https://forum.qt.io/post/745336</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 26 Jan 2023 22:01:12 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:53:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> interesting. I wonder why yours doesn't look like mine. What's your platform and style?</p>
]]></description><link>https://forum.qt.io/post/745335</link><guid isPermaLink="true">https://forum.qt.io/post/745335</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:53:20 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:52:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> <img src="https://ddgobkiprc33d.cloudfront.net/244ba53a-5712-44f1-85d3-31298748a4c4.png" alt="display.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/745334</link><guid isPermaLink="true">https://forum.qt.io/post/745334</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:52:40 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:52:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> look at my picture. The buttons don't look anywhere near half the height of the rectangles. From eyeballing it, it looks more like 1/3 the height.</p>
<p dir="auto"><strong>EDIT:</strong></p>
<p dir="auto">Using a background seems to fix it (sort of). Let me play with this and I'll report back.</p>
]]></description><link>https://forum.qt.io/post/745333</link><guid isPermaLink="true">https://forum.qt.io/post/745333</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:52:42 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:47:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> what do you mean?<br />
r1 height is 60<br />
b1 height is 60 / 2 = 30<br />
my display of the button has the half height.</p>
]]></description><link>https://forum.qt.io/post/745332</link><guid isPermaLink="true">https://forum.qt.io/post/745332</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:47:32 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:43:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> they <em>say</em> 30, but they are <strong>not</strong> half the height of the rectangles I'm placing them in:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/b5a3cab3-1e42-41cf-8f83-7fee01efc252.PNG" alt="buttons.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto"><em>That</em> is what I'm trying to fix (plus another problem I'll bring up later).</p>
<p dir="auto">Thanks...</p>
]]></description><link>https://forum.qt.io/post/745331</link><guid isPermaLink="true">https://forum.qt.io/post/745331</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:43:54 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:44:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> change all of them. I tested the change. They are all 30</p>
<pre><code>import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

ApplicationWindow {
    id: mainWindow
    width: 1024
    height: 768
    visible: true

    ColumnLayout {
        Rectangle {
            id: r1
            height: 60
            width: mainWindow.width
            color: 'red'

            RowLayout {
                id: rowLayout

                Button {
                    id: b1
                    implicitHeight : r1.height / 2
                    text: b1.height
                }
            }
        }

        Rectangle {
            id: r2
            height: 60
            width: mainWindow.width
            color: 'blue'
            Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
            Button {
                id: b2
                implicitHeight: r2.height / 2
                text: b2.height
            }
        }

        Button {
            id: b3
            implicitHeight: r2.height / 2 // just borrowing the height from r2.
            text: b3.height
        }
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/745330</link><guid isPermaLink="true">https://forum.qt.io/post/745330</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:40:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> said in <a href="/post/745327">RoundButton not taking correct height setting</a>:</p>
<blockquote>
<p dir="auto">change<br />
height: r1.height<br />
to<br />
implicitHeight:  r1.height<br />
will do it.</p>
</blockquote>
<p dir="auto">I assume that change was for the RowLayout, as that's the only place with that exact line of code. It didn't change anything. If I make that change to b1 as well, b1 then looks like b2, which isn't what I want.</p>
<blockquote>
<p dir="auto">Setting the implicit size is useful for defining components that have a preferred size based on their content.</p>
</blockquote>
<p dir="auto">But in this case, I want to dictate the size (height) of the button. I want it to be exactly half the height of the rectangle in which it's being placed. That's why I'm not sure implicit sizes are appropriate here.</p>
]]></description><link>https://forum.qt.io/post/745329</link><guid isPermaLink="true">https://forum.qt.io/post/745329</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:40:41 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 21:25:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> said in <a href="/post/745310">RoundButton not taking correct height setting</a>:</p>
<blockquote>
<p dir="auto">height: r1.height</p>
</blockquote>
<p dir="auto">change<br />
height: r1.height<br />
to<br />
implicitHeight:  r1.height<br />
will do it.</p>
<p dir="auto">Setting the implicit size is useful for defining components that have a preferred size based on their content.</p>
]]></description><link>https://forum.qt.io/post/745327</link><guid isPermaLink="true">https://forum.qt.io/post/745327</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 26 Jan 2023 21:25:25 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 26 Jan 2023 18:29:23 GMT]]></title><description><![CDATA[<p dir="auto">Well, I thought I had this figured out, but evidently not. Can someone tell me what is going on here?</p>
<p dir="auto">This code:</p>
<pre><code>import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    id: mainWindow
    width: 1024
    height: 768
    visible: true

    ColumnLayout {
        Rectangle {
            id: r1
            height: 60
            width: mainWindow.width
            color: 'red'

            RowLayout {
                id: rowLayout
                height: r1.height
                width: r1.width

                Button {
                    id: b1
                    height: r1.height / 2
                    text: b1.height
                }
            }
        }
        Rectangle {
            id: r2
            height: 60
            width: mainWindow.width
            color: 'blue'
            Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
            Button {
                id: b2
                height: r2.height / 2
                text: b2.height
            }
        }
        Button {
            id: b3
            height: r2.height / 2 // just borrowing the height from r2.
            text: b3.height
        }
    }
}
</code></pre>
<p dir="auto">yields this:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/efa72b43-6da5-4cc2-aa02-580926c5b3b2.PNG" alt="buttons.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">All buttons should be 30 pixels high (half the height of the rectangles). Buttons 1 and 3 <em>appear</em> as the correct height, but give a bad height value. Button 2 has the correct value, but doesn't appear correctly (not the right height).</p>
<p dir="auto">Can someone tell me WHAT is going on here?</p>
<p dir="auto">Thanks...</p>
]]></description><link>https://forum.qt.io/post/745310</link><guid isPermaLink="true">https://forum.qt.io/post/745310</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 26 Jan 2023 18:29:23 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 19 Jan 2023 15:18:40 GMT]]></title><description><![CDATA[<p dir="auto">I see thanks.</p>
]]></description><link>https://forum.qt.io/post/744459</link><guid isPermaLink="true">https://forum.qt.io/post/744459</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 19 Jan 2023 15:18:40 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 19 Jan 2023 15:19:23 GMT]]></title><description><![CDATA[<p dir="auto">I cut out all the other stuff for brevity. Here's the complete custom button, if you're interested:</p>
<pre><code>// implements a round button that can support an icon and up to two lines of text. (not complete yet)
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects

import QtQuick.Controls.Material
import QtQuick.Controls.Fusion

import colors.stylesheet

RoundButton {
    id: roundButton

    property string buttonTitle: "this should not appear"
    property string buttonDescr: ""
    property int fontSize: 16
    property color textColor: Colors.primaryText
    property color buttonColor: Colors.primaryPurple
    property color borderColor: Colors.primaryText
    property int borderWidth: 2
    property url buttonIcon: ""

    height: implicitHeight//implicitBackgroundHeight
    width: implicitWidth
    radius: height / 2
    leftPadding: 8
    rightPadding: leftPadding
    topPadding: 4
    bottomPadding: 4

    display: AbstractButton.TextBesideIcon
    icon {
        color: roundButton.textColor
        source: roundButton.buttonIcon
        height: roundButton.height * 3 / 4
    }
    text: roundButton.buttonTitle

    // note: this line below is an semi-documented feature,
    // https://doc.qt.io/qt-6/qml-qtquick-palette.html
    // but the alternative is to use contentItem, which
    // doesn't support an icon, so it needs a RowLayout, etc.
    // for now, this is the lesser of 2 evils.
    palette.buttonText: roundButton.textColor

    font {
        pixelSize: roundButton.fontSize
        weight: Font.Bold
    }

    background: Rectangle {
        id: buttonBackground
        height: roundButton.height
        width: roundButton.width
        anchors.centerIn: parent
        radius: height / 2
        color: pressed ? Colors.purplePressed : roundButton.buttonColor
        border.color: borderColor
        border.width: borderWidth
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/744458</link><guid isPermaLink="true">https://forum.qt.io/post/744458</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Thu, 19 Jan 2023 15:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Thu, 19 Jan 2023 14:46:05 GMT]]></title><description><![CDATA[<p dir="auto">background code seems not to do anything.</p>
<pre><code>    background: Rectangle {
        id: buttonBackground
        height: roundButton.height
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/744452</link><guid isPermaLink="true">https://forum.qt.io/post/744452</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Thu, 19 Jan 2023 14:46:05 GMT</pubDate></item><item><title><![CDATA[Reply to RoundButton not taking correct height setting on Wed, 18 Jan 2023 23:17:43 GMT]]></title><description><![CDATA[<p dir="auto">I found the problem - it was specific to the Material style. Fixed by making the following customizations to RoundButton (deleted irrelevant code):</p>
<pre><code>RoundButton {
    id: roundButton
    height: implicitBackgroundHeight
    background: Rectangle {
        id: buttonBackground
        height: roundButton.height
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/744324</link><guid isPermaLink="true">https://forum.qt.io/post/744324</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Wed, 18 Jan 2023 23:17:43 GMT</pubDate></item></channel></rss>