-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMyIconButton.qml
executable file
·75 lines (66 loc) · 2.19 KB
/
MyIconButton.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import QtQuick 2.0
/* 桌面按钮的实现,左边图标,右边文本 */
Rectangle {
id: root
visible: true
/* width: 140
height: 40*/
width: icon.implicitWidth + button.implicitWidth + root.margin*2
height: icon.implicitHeight + button.implicitHeight-5
radius: 5
color: clr_exited
// border.color: "brown"
// border.width: 1
property alias icon_code: icon.text
property alias icon_size: icon.width
property alias button_text: button.text
property color button_color: "white"
property alias button_size: button.font.pixelSize
property color clr_backgroud: "transparent" //背景透明色
property color clr_entered: "lightgray"
property color clr_exited: "transparent"
property color clr_pressed: "teal" //点击效果
property int margin: 10
signal clicked
signal doubleClicked
Text {
id: icon
font.family: "FontAwesome"
font.pixelSize: 25
text: Define.iconCode_back //返回图标
color: button_color
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
anchors.verticalCenter: root.verticalCenter
anchors.left: root.left
anchors.leftMargin: root.margin
}
Text {
id: button
text: qsTr("返回")
color: "white"
font.bold: false
font.family: "Microsoft Yahei"
font.pixelSize: 18
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
anchors.verticalCenter: root.verticalCenter
anchors.verticalCenterOffset: -2
anchors.left: icon.right
anchors.leftMargin: root.margin/2
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton; //只接受左键
hoverEnabled: true
onClicked: root.clicked()
onEntered: root.color = clr_entered
onExited: root.color = clr_exited
onReleased: root.color = clr_exited
onPressed: root.color = clr_pressed;
onDoubleClicked: {
root.doubleClicked();
// root.color = clr_entered;
}
}
}