我正在尝试在QML中创建自定义对象,但没有成功。我错过了一些小而重要的东西吗?
这是代码
some.qml
import QtQuick 2.0
Rectangle {
id: devicesList
width: 100
height: 62
color: "red"
ListElement {}
}
ListElement.qml
import QtQuick 2.0
Rectangle {
id: aaa
x: 100
y: 100
//x: ListElementRoot.xx
// y: ListElementRoot.yy
width: 100
height: 100
radius: 10
color: "blue"
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onEntered:{
animation.start()
animation2.start()
animation3.start()
}
//onClicked: aaa.width -= 10
//onEntered:
}
PropertyAnimation {
id: animation
target: aaa
properties: "height"
to: "200"
duration: 1000
}
PropertyAnimation {
id: animation2
target: {
rotation
}
properties: "angle"
to: "72"
duration: 1000
}
PropertyAnimation {
id: animation3
target: g1
properties: "color"
to: "gray"
duration: 500
}
transform: Rotation {
id: rotation
origin.x: 30
origin.y: 30
axis {
x: 1
y: 0
z: 0
}
angle: 0
}
gradient: Gradient {
GradientStop { id: g1; position: 0.0; color: "blue" }
GradientStop { id: g2; position: 1.0; color: "blue" }
}
states: State{
name: "moved"; when: mouseArea.entered
PropertyChanges { target: aaa; width: width+10; height: height+10 }
}
transitions: Transition {
NumberAnimation { properties: "width,height"; duration: 1000 }
}
}
我已经尝试过这个版本,并简化了只有x,y,宽度,高度和颜色属性的版本,没有用。
答案 0 :(得分:0)
解决。我一直试图覆盖核心对象。