记录Qtquick核心编程学习记录
import QtQuick 2.5
Rectangle{
width:300;
height:400;
id:root;
color:"green";
MouseArea{
id:mouseArea;
anchors.fill: parent;
acceptedButtons: Qt.LeftButton | Qt.RightButton;
onClicked: {
if(mouse.button == Qt.RightButton)
{
Qt.quit();
}
else if(mouse.button == Qt.LeftButton)
{
color = Qt.rgba( (mouse.x % 255)/255.0, (mouse.y % 255) / 255.0, 0.6, 1.0 );
}
}
onDoubleClicked: {
color = "red";
}
}
}
效果说明:根据鼠标左键点击颜色变化,右键退出,双击变红。