Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QML: how to handle mouse over?

Tags:

qt

qt-quick

qml

QML: how to handle mouse over event on MouseArea? Can any one provide simple example or say what is wrong with mine?

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()
    }
}
like image 689
myWallJSON Avatar asked Apr 19 '12 07:04

myWallJSON


1 Answers

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()
   }
}
like image 165
Arpegius Avatar answered Sep 19 '22 14:09

Arpegius