Depending on how your application is structured, the best way could be to pass in the window that the tray icon shall control as a property from "further up" your user interface structure.
First, extend your tray icon component and add a "window" property to it:
import QtQuick 2.9 import QtQuick.Window 2.2 import Qt.labs.platform 1.0 SystemTrayIcon { id: trayIcon // this property holds the window the tray icon controls: property Window window visible: true iconSource: "qrc:/icons/ic_tray.png" menu: Menu { MenuItem { text: qsTr("Settings") onTriggered: { trayIcon.window.show(); } } MenuItem { text: qsTr("Quit") onTriggered: Qt.quit() // Just hide an existing } } }
Now, you could instantiate your tray icon e.g. in your main window like this:
import QtQuick 2.9 import QtQuick.Window 2.2 Window { id: mainWindow width: 800 height: 600 TrayIcon { window: mainWindow } }
In this case, the tray icon would control the main window itself; however, you can easily create a single instance of a settings window within the main window and pass that one to the tray icon.