Background application is not receiving focus on hiding my Qt Quick application in macOS
-
Hi,
I have an application like Spotlight Search on macOS. On pressing the escape key, I want to hide this application and set the focus to the background application just like Spotlight Search. The application is getting hidden, but the background application is not receiving focus. What am I doing wrong?
main.qml Code:
import QtQuick 2.9 import QtQuick.Window 2.2 import "qrc:/ApplicationContainer/qml" import "qrc:/SearchBoxWidget/js/SearchBoxWidget.js" as SearchBox Window { readonly property int shadowWidth: 10 id: root visible: false flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint width: container.width + 2 * shadowWidth height: container.height + 2 * shadowWidth x: Screen.width/2 - width/2 y: Screen.height/7 color: "transparent" onActiveChanged: { if(!active && visible) { SearchBox.dismissApp() } } ApplicationContainer { id: container width: 640 height: childrenRect.height x: parent.x + shadowWidth y: parent.y + shadowWidth } }
ApplicationContainer.js
import QtQuick 2.12 import QtGraphicalEffects 1.12 import QtQuick.Controls 2.12 import "qrc:/SearchBoxWidget/js/SearchBoxWidget.js" as SearchBox Rectangle { radius: 10 layer.enabled: true layer.effect: Glow { cached: true radius: 15 spread: 0.2 samples: (2 * radius) + 1 color: Theme.defaultColor.layer transparentBorder: true } /* here search box code*/ Keys.onEscapePressed: { SearchBox.dismissApp() } }
SearchBoxWidget.js
function dismissApp() { root.hide(); }
Any help will be highly appreciated.