I have a Button which text changes and when its text changes, its width also changes. I want to animate this change in width when I change the text. How can I do that ?
I tried following but its not working
import QtQuick.Window 2.15
import QtQuick 2.15
import QtQuick.Controls 2.15
Window {
width: 500
height: 600
visible: true
Button {
property bool t: false
text : t ? "very more text hahaha haha hehe" : "less text"
onClicked: t = !t
Behavior on width {
NumberAnimation {
duration: 1000
}
}
}
}
The change of the Button width is a byproduct of its implicitWidth being changed here.
By changing the Behavior to trigger on implicitWidth
instead of width
you will have your expected behavior.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.