Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Identical Code in Multiple Signal Handlers Causes Silent Failure
Forum Updated to NodeBB v4.3 + New Features

Identical Code in Multiple Signal Handlers Causes Silent Failure

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 188 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wallace Stevens
    wrote last edited by
    #1

    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 entirely

    Environment:

    Qt 6.8.0
    Windows 11

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wallace Stevens
      wrote last edited by
      #2

      image.png
      image.png

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved