Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Connections problem



  • I have a signal in C++:

    emit(mySignal(bool));
    

    I have a connection in qml:

    Connections {​​​​​​​
      target: cppObject
      onMySignal: argument ? "true" : "false"
    }​​​​​​​
    

    When I surround the connection in curly braces:

    Connections {​​​​​​​​
      target: cppObject
      onMySignal: {​​​​​​​ argument ? "true" : "false" }​​​​​​​
    }​​​​​​​​
    

    I get aReferenceError that argument is not defined, but not with the curly braces, why is this?


  • Qt Champions 2017

    What is argument here ? Either way it should give you problem. Argument should be variable name defined in your signal. I did not see that. Also when you emit the signal, you should give the value than type. Here you are adding as bool. It should true/false


Log in to reply