therecipe / qt

Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly
GNU Lesser General Public License v3.0
10.38k stars 736 forks source link

Trying to use system tray in QML got the error "module Qt.labs.platform is not installed" #1074

Open nandohenrique opened 4 years ago

nandohenrique commented 4 years ago

I'm trying integrating the system tray component in the QML file, but when I run the docker static image for windows or Linux I got the error "module Qt.labs.platform is not installed". However, if I run a command locally for example "qtdeploy -debug build linux ." it's run successfully and the message from system tray appears.

Code example:

import Qt.labs.platform 1.1

SystemTrayIcon {
    id: systemTray
    visible: true
    icon.source: "qrc:/images/icon.svg"

    menu: Menu {
            MenuItem {
                text: qsTr("Open")
                onTriggered: {
                    app.showNormal()
                }
            }
            MenuItem {
                text: qsTr("Quit")
                onTriggered: Qt.quit()
            }
        }
}

ClientService {
    id: clientService

    onUpdateProcessingStatus: {
       systemTray.showMessage('Foo:', 'Bar!', null, 3000);
    }
}
jipson7 commented 4 years ago

Could you also post your golang code to load the qml?. I'm not sure I have a solution but Im working on the same problem.

nandohenrique commented 4 years ago

Yes sure. My Golang code is like this:

gui.NewQGuiApplication(len(os.Args), os.Args)

var qmlBridge = NewQmlBridge(nil)

var app = qml.NewQQmlApplicationEngine(nil)
app.RootContext().SetContextProperty("QmlBridge", qmlBridge)
app.Load(core.NewQUrl3("qrc:/qml/main.qml", 0))

gui.QGuiApplication_Exec()

It works when I execute it locally, but if I use the docker image it does not work

RokeJulianLockhart commented 1 year ago

@nandohenrique, install qml-module-qt-labs-platform, perhaps?