-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyButton.qml
43 lines (39 loc) · 1.03 KB
/
MyButton.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
import QtQuick 2.0
import QtQuick.Controls 2.0
Rectangle {
id: rec
width: 100; height: 100
color: "#80BBF7"
property string customText: "hh"
property int fontSize: 14
property string toolTipText: "click me !"
property color oldColor: "#ffffff"
signal buttonClicked()
Text {
id: name
text: qsTr(customText)
font.pointSize: fontSize
verticalAlignment: Text.AlignVCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
id: mouseArea
hoverEnabled: true
anchors.fill: parent
onClicked: console.log("Button clicked!"),buttonClicked()
ToolTip{
id:toolTip
text:toolTipText
}
onEntered:{
oldColor = rec.color
rec.color = Qt.lighter( rec.color,1.2)
toolTip.visible = true
}
onExited: {
rec.color = oldColor
toolTip.visible = false
}
}
}