我在 QML 中有带有自定义委托的 ListView 项目:
Component{
id: contactDelegate
Item
{
id: wrapper;
width: 306; height: 40
FlipableImage
{
id: flipableImage
width: 30
height: 30
anchors.verticalCenter: wrapper.verticalCenter;
anchors.left: wrapper.left
anchors.leftMargin: 10
frontImage: serverIconSource;
backImage: "qrc:/images/resources/images/log.png";
}
Column
{
anchors.left: flipableImage.right
anchors.leftMargin: 10
Text
{
font.family: helveticaNeueBoldFont.name
font.pixelSize: 14
text: serverName;
}
Text
{
font.family: helveticaNeueFont.name
font.pixelSize: 14
text: serverLogin;
}
}
ConnectionStateImage
{
id: stateImage
state: "noState"
anchors.verticalCenter: parent.verticalCenter;
anchors.right: wrapper.right
anchors.rightMargin: 10
visible: itemMouseArea.containsMouse;
}
MouseArea
{
id: mouseArea;
anchors.fill: flipableImage
hoverEnabled: true;
z: 1
onEntered:
{
flipableImage.flipped = !flipableImage.flipped;
}
onExited:
{
flipableImage.flipped = !flipableImage.flipped;
}
}
}
}
鼠标悬停flipableImage翻转。但我需要在模型或 QDeclarativeView 的事件上手动翻转它。如何导航到列表视图中的项目以更改 FlipableImage 的属性。从 qml 或 C++ 导航对我来说并不重要。谢谢。