How to capture a signal in QML?

后端 未结 4 1935
南方客
南方客 2021-02-08 04:50

How I can send s signal from one qml component to another?

Below is an example:

Rectangle {
    id: main
    width: 360; height: 360
    signal clicked()         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 05:44

    In the other object, you simply add a on word followed by the signal name. EG:

    Rectangle {
      YourQmlObject {
        onClicked: { ... }
      }
    }
    

    (clicked is somewhat a confusing signal name because it's common. But if you had called your signal orange, you'd make the binding onOrange:)

提交回复
热议问题