QQuickWidget embeded in QDialog has no hover effection at show
-
A. My trouble:
I embed aQQuickWidgetintoQDialog.
But the qmlMouseAreaofButtonwill have no hover effection after showing until I clicked any position (also desktop).It would have hover effection if I replace
dialog.exec()withdialog.show()or exec withWindowModality. ( I need ApplicationModality.)B. What I have tried but no use:
I used to try giving focus to
MouseAreain qml byTimer, callingforceActive()in cpp,setFocus()etc, andQcoreApplication::postEvent(MousePressEvent...).C. My idea
I don't know how to solve it, maybe I will replaceQDialogwithQQuickView.I use
QQuickWidgetinQDialogto reuse some cpp implementation ( frameless, shadow and corner with radius).I’m hoping to hear your thoughts.

WidgetQuickDialog dialog; dialog.SetContentText(text); dialog.exec();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 } } */ } } }