Identical Code in Multiple Signal Handlers Causes Silent Failure
-
I've encountered a peculiar issue with QML signal handlers that I can't explain. When I have identical code in multiple signal handlers (like onClicked and onTriggered), the application silently fails to work. Here's a minimal example to demonstrate:
// ApplicationWindow.qml import QtQuick import QtQuick.Controls import QtQuick.Layouts import Qt.labs.platform as Platform ApplicationWindow { ToolButton { text: "Home" onClicked: { WindowManager.open("ui.page", "Home", { parent: root, mode: WindowManager.Reuse }); } } Platform.SystemTrayIcon { menu: Platform.Menu { Platform.MenuItem { text: "Home" onTriggered: { WindowManager.open("ui.page", "Home", { parent: root, mode: WindowManager.Reuse }); } } } } }
If I use this code in either onClicked or onTriggered alone, it works perfectly
If I have the same code in both handlers, the application silently fails (no errors, no warnings)
Even commenting out one of the handlers (instead of deleting) doesn't fix it - I must completely remove one
The code works again after removing one handler entirelyEnvironment:
Qt 6.8.0
Windows 11 -
If the code within the signal handler is the same, the program can be compiled but it will fail to run and even cannot be debugged.