<?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[QQuickWidget embeded in QDialog has no hover effection at show]]></title><description><![CDATA[<p dir="auto">A. My trouble:<br />
I embed a <code>QQuickWidget</code> into  <code>QDialog</code>.<br />
But the qml <code>MouseArea</code>  of <code>Button</code> will have no hover effection after showing until I clicked any position (also desktop).</p>
<p dir="auto">It would have hover effection if I replace <code>dialog.exec()</code> with <code>dialog.show()</code> or exec with <code>WindowModality</code>. ( I need ApplicationModality.)</p>
<p dir="auto">B. What I have tried but no use:</p>
<p dir="auto">I used to try giving focus to <code>MouseArea</code> in qml by <code>Timer</code>, calling <code>forceActive()</code> in cpp, <code>setFocus()</code> etc, and <code>QcoreApplication::postEvent(MousePressEvent...)</code>.</p>
<p dir="auto">C. My idea<br />
I don't know how to solve it, maybe I will replace <code>QDialog</code> with <code>QQuickView</code>.</p>
<p dir="auto">I use <code>QQuickWidget</code> in <code>QDialog</code> to reuse some cpp implementation ( frameless, shadow and corner with radius).</p>
<p dir="auto">I’m hoping to hear your thoughts.</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/4f0db792-83b6-49a4-a4d5-a0996bd0864f.png" alt="bbf0a522-a429-462d-a73d-a840ea476ee3-image.png" class=" img-fluid img-markdown" /></p>
<pre><code class="language-cpp">    WidgetQuickDialog dialog;
    dialog.SetContentText(text);
    dialog.exec();
</code></pre>
<pre><code class="language-javascript">import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: root

    property string btnRightText: "btnRightText"
    property string contentText: "contentText"

    signal signalBtnRightClicked

    anchors.fill: parent

    Rectangle {
        anchors.fill: parent
        color: "white"
    }
    ColumnLayout {
        anchors.fill: parent

        Text {
            Layout.fillWidth: true
            color: "#1C1F23"
            text: root.contentText

            font {
                family: "PingFang SC"
                pixelSize: 16
            }
        }
        Item {
            Layout.fillHeight: true
            Layout.fillWidth: true
        }
        Button {
            function getBgColor() {
                var normalColor = "#00C221";
                if (pressed) {
                    return Qt.darker(normalColor, 1.2);
                } else if (hovered) {
                    return Qt.darker(normalColor, 1.1);
                }
                return normalColor;
            }

            Layout.alignment: Qt.AlignRight | Qt.AlignBottom
            Layout.bottomMargin: 15
            Layout.preferredHeight: 40
            Layout.preferredWidth: 100
            Layout.rightMargin: 20
            text: root.btnRightText

            background: Rectangle {
                color: parent.getBgColor()
                radius: 4
            }

            onPressed: root.signalBtnRightClicked()

            font {
                family: "PingFang SC"
                pixelSize: 18
                weight: 600
            }
            MouseArea {
                id: btnMouseArea

                anchors.fill: parent
                cursorShape: Qt.PointingHandCursor
                enabled: true
                hoverEnabled: true
                propagateComposedEvents: true

                onPressed: function (mouse) {
                    mouse.accepted = false;
                }
            }
            /* Just a try, ths log will outputs but still no hover effection
            Timer {
                interval: 500
                repeat: false
                running: true

                onTriggered: {
                    console.log("hello world")
                    btnMouseArea.forceActiveFocus();
                    btnMouseArea.entered();
                    btnMouseArea
                }
            }
            */
        }
    }
}

</code></pre>
]]></description><link>https://forum.qt.io/topic/163678/qquickwidget-embeded-in-qdialog-has-no-hover-effection-at-show</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 07:53:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/163678.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Nov 2025 16:35:51 GMT</pubDate><ttl>60</ttl></channel></rss>