QML:如何处理MouseArea上的鼠标悬停事件?谁能提供一个简单的例子,或者说我的问题是什么?

import QtQuick 1.1
Image {
    source: "quit.png"
    scale:  mouseArea.containsMouse ? 0.8 : 1.0
    smooth: quitMouse.containsMouse
    MouseArea {
        id: quitMouse
        anchors.fill: parent
        anchors.margins: -10
        onClicked: Qt.quit()
    }
}

最佳答案

import QtQuick 1.1
Image {
   source: "quit.png"
   scale:  mouseArea.containsMouse ? 0.8 : 1.0
   smooth: mouseArea.containsMouse
   MouseArea {
       id: mouseArea
       anchors.fill: parent
       anchors.margins: -10
       hoverEnabled: true         //this line will enable mouseArea.containsMouse
       onClicked: Qt.quit()
   }
}

09-05 22:57