This QML module provides light weight SystemTrayIcon element.
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.SystemTrayIcon 2.15
SystemTrayIcon {
id: systemTrayIcon
quitOnLastWindowClosed: false
visible: true
icon: Image {
id: image
source: 'heart.png'
}
contextMenu: Menu {
Action {
icon.name: 'document-open'
text: qsTr("Open")
}
Action {
icon.name: 'document-close'
text: qsTr("Close")
}
}
}
Qt Labs Platform plugin provides SystemTrayIcon. However, as the documentation says, it needs the QtWidgets library just for a system tray icon because it uses QSystemTrayIcon internally.
This QtQuick.SystemTrayIcon doesn't depend on QtWidgets.
- Perl
- Qt 5.15 or later
- QtGui
- QtQuick
- QtQuick Controls 2
$ git clone https://github.com/signal-slot/qtquicksystemtrayicon.git
$ mkdir build
$ cd $_
$ /path/to/qmake ../qtquicksystemtrayicon
$ make
$ make sub-examples
$ export QML2_IMPORT_PATH=$PWD/qml
$ ./qtquicksystemtrayicon/examples/quicksystemtrayicon/quick/quick