add code
This commit is contained in:
70
4DemoApp/MButton.qml
Normal file
70
4DemoApp/MButton.qml
Normal file
@@ -0,0 +1,70 @@
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: rootId
|
||||
property alias buttonText: buttonTextId.text
|
||||
width: containerRectId.width
|
||||
height: containerRectId.height
|
||||
|
||||
signal buttonClicked
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: containerRectId
|
||||
signal greet(string message)
|
||||
color: "red"
|
||||
border {
|
||||
color: "blue"
|
||||
width: 3
|
||||
}
|
||||
|
||||
width: buttonTextId.implicitWidth + 20
|
||||
height: buttonTextId.implicitHeight + 20
|
||||
|
||||
Text {
|
||||
id: buttonTextId
|
||||
text: "MButton"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseAreaId
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
// onClicked: {
|
||||
// // console.log("Clicked on button" + buttonTextId.text)
|
||||
// rootId.buttonClicked()
|
||||
// }
|
||||
// onClicked: function(mouse) {
|
||||
// console.log(mouse.x)
|
||||
// }
|
||||
// onClicked: (mouse_param) => console.log(mouse_param.x)
|
||||
|
||||
// onEntered: {
|
||||
// console.log("enter")
|
||||
// }
|
||||
}
|
||||
onGreet: function(message) {
|
||||
console.log("Greeting with message: " + message);
|
||||
}
|
||||
function respond_your_way(message) {
|
||||
console.log("Responding our way;Greeting with message: " + message);
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
target: mouseAreaId
|
||||
function onClicked() {
|
||||
// console.log("Hello")
|
||||
containerRectId.greet("Hello Lenn")
|
||||
}
|
||||
function onDoubleClicked(mouse) {
|
||||
console.log("DoubleClicked at: " + mouse.x)
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
containerRectId.greet.connect(containerRectId.respond_your_way)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user