QML鼠标区域控制

鼠标操作使用很多,下面给出一个示例:

 1 import QtQuick 2.4
 2 import QtQuick.Controls 1.3
 3 import QtQuick.Window 2.2
 4 import QtQuick.Dialogs 1.2
 5 
 6 Rectangle{
 7     id: root
 8      210
 9     height: 100
10 
11     Rectangle{
12         id: rect1
13          100; height:100
14         color: "lightsteelblue"
15         MouseArea{
16             anchors.fill: parent
17 
18             onClicked: {
19                 rect2.visible = !rect2.visible
20                 console.log("visible: ", rect2.visible)
21             }
22         }
23     }
24 
25     Rectangle{
26         id: rect2
27         x:110; y:0
28          100; height:100
29         color: "lightsteelblue"
30         border.color: "lightgreen"
31         border. 5
32         radius: 10
33     }
34 
35 }
原文地址:https://www.cnblogs.com/xiaomanon/p/4544061.html