[Interest] QML onActivated reason always 3

Emre Besirik nomercy at gmail.com
Wed Jul 18 10:53:00 CEST 2018


Hi,

I’m toying with QtQuick and QML for a few days and found that the reason is always 3 no matter how I click the icon in the following code;

import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.2
import Qt.labs.platform 1.0

Window {
    id: root
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    SystemTrayIcon {
        id: trayIcon
        visible: true
        iconSource: "qrc:/icon.png"

        onActivated: {
            console.log("reason: " + reason)
            if(reason === 1){
                trayMenu.open()
            } else {
                if(root.visibility === Window.Hidden){
                    root.show()
                    root.raise()
                    root.requestActivate()
                } else {
                    root.hide()
                }
            }
        }
    }

    Menu {
        id:trayMenu
        enabled: true
        MenuItem {
            text: qsTr("Quit")
            onTriggered: Qt.quit()
        }
    }
}

is there a way to fix this? (trying on macos but want it to work cross platform eventually)

Regards,

Emre Besirik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180718/8c284802/attachment.html>


More information about the Interest mailing list