When I click the button after 5 seconds it will turn green and then will return to its former color. I try to do it with timer function but it doesn't work. In QML Language
CodePudding user response:
This is just an example, but it's working using a Timer in QML:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
visible: true
width: 300
height: 300
Timer {
id: myTimer
interval: 5000; repeat: false
onTriggered: myButton.background.color = "blue"
}
Button {
id: myButton
x: 100
y: 100
text: "my button"
background: Rectangle {
color: "blue"
}
onClicked: {
myButton.background.color = "green"
myTimer.start();
console.log("clicked");
}
}
}