connections 使用
import QtQuick 2.9import QtQuick.Window 2.2Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Rectangle{ visible: true id: rect width: 100 height: 100 color: "#000000" MouseArea{ id:mousea anchors.fill: parent } Connections{ target: mousea onClicked:rect.color = Qt.rgba(Math.random(),Math.random(),Math.random(),1) } }}