Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Background application is not receiving focus on hiding my Qt Quick application in macOS

Background application is not receiving focus on hiding my Qt Quick application in macOS

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 219 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Strictly_Prohibited
    wrote on last edited by Strictly_Prohibited
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved