TL; DR; No, you have misunderstood. SystemTrayIcon
needs you to use QApplication
.
Explanation:
SystemTrayIcon
is a QSystemTrayIcon
wrapper that can be used in QML and therefore it is necessary to use QApplication
, and that is indicated in the docs:
Availability
A native system tray icon is currently available on the following
platforms:
- All window managers and independent tray implementations for X11 that implement the freedesktop.org XEmbed system tray specification.
- All desktop environments that implement the freedesktop.org D-Bus StatusNotifierItem specification, including recent versions of KDE and
Unity.
- All supported versions of macOS. Note that the Growl notification system must be installed for showMessage() to display messages on OS X
prior to 10.8 (Mountain Lion).
The Qt Labs Platform module uses Qt
Widgets as a fallback on platforms that do not have a native
implementation available. Therefore, applications that use types from
the Qt Labs Platform module should link to QtWidgets and use
QApplication instead of QGuiApplication.
To link against the QtWidgets library, add the following to your qmake
project file:
QT += widgets
Create an instance of QApplication in main():
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
Note: Types in Qt.labs modules are not guaranteed to remain compatible
in future versions.
(emphasis mine)