&引用;应为令牌''&引用;在QML中的信号处理程序中使用转换属性时
我想在鼠标悬停的情况下为一个&引用;应为令牌''&引用;在QML中的信号处理程序中使用转换属性时,qml,syntax-error,Qml,Syntax Error,我想在鼠标悬停的情况下为一个矩形进行转换。我随后创建了一个MouseArea,如下所示: MouseArea{ anchors.fill: parent hoverEnabled: true onEntered: { rMT.color = 'red' // rMT is my rectangle's id (rectangle_mouse_tracking) t
矩形
进行转换。我随后创建了一个MouseArea
,如下所示:
MouseArea{
anchors.fill: parent
hoverEnabled: true
onEntered: {
rMT.color = 'red' // rMT is my rectangle's id (rectangle_mouse_tracking)
transitions: Transition { // Expected token ','
NumberAnimation {
property : "width"
easing.type: Easing.InOutQuad
duration : 200
}
}
}
...
...
*有其他可能的方法来制作动画,但我想知道上面的代码有什么问题
目前我是QML的noob。如果这个问题有点傻,我很抱歉
谢谢。属性更改时,将执行过渡中定义的动画 如果希望在
宽度
更改时执行动画,请更改onenterned中的宽度,并将执行矩形中定义的过渡
语法错误是因为转换
必须在Rectange{}中,而不是在onenterned{}
import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick 2.0
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
id: rMT
width: 400
height:400
x:0
color: 'blue'
border.color: 'black'
MouseArea{
anchors.fill: parent
hoverEnabled: true
onEntered: {
rMT.color = 'red'
rMT.width = 100
}
}
transitions: Transition{
NumberAnimation {
property : "width"
from: 400
easing.type: Easing.InOutQuad
duration : 2000
}
}
}
}
好的。但是“持续时间”和“放松”根本没有效果。为什么?如果你不使用状态,那么转换就是使用状态使用行为。