-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.qml
40 lines (33 loc) · 957 Bytes
/
Square.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import QtQuick 2.0
Item {
id: square
property int squareStatus: 0
property int squareSize: 100
property int position: 0
signal onClickedSquare(int index);
width: squareSize
height: squareSize
Rectangle {
width: squareSize
height: squareSize
color: "green"
border.color: "black"
border.width: squareSize / 100
Rectangle {
anchors.centerIn: parent
width: parent.width / 10 * 9
height: parent.width / 10 * 9
color: squareStatus === 1 ? "white"
: squareStatus === 2 ? "black" : "transparent"
radius: parent.width / 2
MouseArea {
anchors.fill: parent
onClicked: {
console.log("clicked")
console.log("Pos:" + position)
onClickedSquare(position)
}
}
}
}
}