qml connections使用

connections 使用

import QtQuick 2.9
import QtQuick.Window 2.2

Window {
    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)
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/CQbk/p/9509528.html
QML