Rectangle
을 사용하여 만든 카드가 있다고 가정 해 보겠습니다. 클릭 할 때 버튼 위에 표시하고 싶습니다. 나는 그 일을 위해 showMenu()
함수를 호출하고 있는데, 나는 ListView
을 동적 인 ListModel
과 함께 사용하고있다. 이러한 문제는 버튼이 상단 대신에 Rectangle
아래에 추가 된 것입니다. 항목을 모델에 추가 한 후 앵커가 업데이트되지 않습니다. 여기 내 코드가ListView 동적 앵커링
Item {
width: 120
height: 120
Rectangle {
id: card
width: 50
height: 100
color: "pink"
anchors.bottom: parent.bottom
Item {
id: rec
width: 50
anchors.bottom: parent.top // This anchor is not updating after appending an item to the list.
ListModel {
id: menuListModel
}
Component {
id: delegate
Rectangle {
width: 120
height: 20
color: "blue"
Text {
anchors.fill: parent
anchors.centerIn: parent
text: commandText
}
}
}
ListView {
anchors.fill: parent
model:menuListModel
delegate: delegate
interactive: false
}
}
MouseArea {
anchors.fill: parent
onClicked: menuListModel.append({"commandText" : "Normal Summon"});
}
}
}
실행할 코드를 게시 할 수 있습니까? – Mitch
이 예제를 업데이트했습니다. –