<?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[I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work!]]></title><description><![CDATA[<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/2424fe0f-a555-4105-8006-fb32f1067e05.png" alt="2022-12-22 04 55 20.png" class=" img-fluid img-markdown" /> <img src="https://ddgobkiprc33d.cloudfront.net/7b915d0f-9f0d-4562-b89e-934d5554047c.png" alt="2022-12-22 04 56 17.png" class=" img-fluid img-markdown" /><br />
When I mouse over it, it doesn't change the "font color", what's wrong with it?</p>
]]></description><link>https://forum.qt.io/topic/141653/i-ve-been-trying-for-a-long-time-can-anyone-tell-me-why-custombuttom-s-control-hovered-doesn-t-work</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 04:31:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141653.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Dec 2022 21:00:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Fri, 23 Dec 2022 15:16:54 GMT]]></title><description><![CDATA[<p dir="auto">States have a priority.  The lower in the list (comes first) will have priority over states later in the list.  So your "normal" state will have priority over the "hovered" state.  Thus it will never show anything on hover as either "normal" and "down" will always be active.</p>
]]></description><link>https://forum.qt.io/post/741308</link><guid isPermaLink="true">https://forum.qt.io/post/741308</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Fri, 23 Dec 2022 15:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Fri, 23 Dec 2022 14:38:14 GMT]]></title><description><![CDATA[<p dir="auto">I'm assuming you already figured it out, but making that bool part of the button itself and not of some state will fix this.</p>
]]></description><link>https://forum.qt.io/post/741305</link><guid isPermaLink="true">https://forum.qt.io/post/741305</guid><dc:creator><![CDATA[TomZ]]></dc:creator><pubDate>Fri, 23 Dec 2022 14:38:14 GMT</pubDate></item><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Wed, 21 Dec 2022 22:11:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomz">@<bdi>TomZ</bdi></a> In the properties view, 2 of them are already checked. But it is missing in qml.</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/471241ac-82b8-4370-81ee-3d7720d88931.png" alt="2022-12-22 05 56 55.png" class=" img-fluid img-markdown" /><br />
<img src="https://ddgobkiprc33d.cloudfront.net/13fd3c9a-95e3-4b27-8149-4b1ccd8c2db8.png" alt="2022-12-22 05 57 33.png" class=" img-fluid img-markdown" /><br />
I unchecked and then re-checked and a line appeared in the qml code within the normal state.<br />
<img src="https://ddgobkiprc33d.cloudfront.net/96457b75-a8dd-46b3-ab4d-9abc097ff585.png" alt="2022-12-22 06 10 22.png" class=" img-fluid img-markdown" /><br />
But it still doesn't work.</p>
]]></description><link>https://forum.qt.io/post/741045</link><guid isPermaLink="true">https://forum.qt.io/post/741045</guid><dc:creator><![CDATA[hilod]]></dc:creator><pubDate>Wed, 21 Dec 2022 22:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Wed, 21 Dec 2022 21:48:09 GMT]]></title><description><![CDATA[<p dir="auto">I'm missing a <code>hoverEnabled: true</code> in your file.</p>
]]></description><link>https://forum.qt.io/post/741044</link><guid isPermaLink="true">https://forum.qt.io/post/741044</guid><dc:creator><![CDATA[TomZ]]></dc:creator><pubDate>Wed, 21 Dec 2022 21:48:09 GMT</pubDate></item><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Wed, 21 Dec 2022 21:11:19 GMT]]></title><description><![CDATA[<p dir="auto">I just added a State (hovered) and left everything else unchanged.</p>
<p dir="auto">Here is the code：</p>
<pre><code>

/*
This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only.
It is supposed to be strictly declarative and only uses a subset of QML. If you edit
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15

Button {
    id: control
    width: 100
    height: 60

    implicitWidth: Math.max(
                       buttonBackground ? buttonBackground.implicitWidth : 0,
                       textItem.implicitWidth + leftPadding + rightPadding)
    implicitHeight: Math.max(
                        buttonBackground ? buttonBackground.implicitHeight : 0,
                        textItem.implicitHeight + topPadding + bottomPadding)
    leftPadding: 4
    rightPadding: 4

    text: "My Button"

    background: buttonBackground
    Rectangle {
        id: buttonBackground
        color: "#00000000"
        implicitWidth: 100
        implicitHeight: 40
        opacity: enabled ? 1 : 0.3
        radius: 2
        border.color: "#047eff"
    }

    contentItem: textItem
    Text {
        id: textItem
        text: control.text

        opacity: enabled ? 1.0 : 0.3
        color: "#047eff"
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }

    states: [
        State {
            name: "normal"
            when: !control.down

            PropertyChanges {
                target: buttonBackground
                color: "#00000000"
                border.color: "#047eff"
            }

            PropertyChanges {
                target: textItem
                color: "#047eff"
            }
        },
        State {
            name: "down"
            when: control.down
            PropertyChanges {
                target: textItem
                color: "#ffffff"
            }

            PropertyChanges {
                target: buttonBackground
                color: "#047eff"
                border.color: "#00000000"
            }
        },
        State {
            name: "hovered"
            when: control.hovered

            PropertyChanges {
                target: textItem
                color: "#ff04e4"
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
            }
        }
    ]
}

</code></pre>
]]></description><link>https://forum.qt.io/post/741042</link><guid isPermaLink="true">https://forum.qt.io/post/741042</guid><dc:creator><![CDATA[hilod]]></dc:creator><pubDate>Wed, 21 Dec 2022 21:11:19 GMT</pubDate></item><item><title><![CDATA[Reply to I&#x27;ve been trying for a long time, can anyone tell me why CustomButtom&#x27;s control.hovered doesn&#x27;t work! on Wed, 21 Dec 2022 21:05:07 GMT]]></title><description><![CDATA[<p dir="auto">it helps if you actually share the sourcecode of your MyButton.ui.qml file</p>
<p dir="auto">ps. you need to edit the sourcecode to fix things, was that among the things you tried?</p>
]]></description><link>https://forum.qt.io/post/741040</link><guid isPermaLink="true">https://forum.qt.io/post/741040</guid><dc:creator><![CDATA[TomZ]]></dc:creator><pubDate>Wed, 21 Dec 2022 21:05:07 GMT</pubDate></item></channel></rss>