Hi Qt Masters,
I'm having problem displaying a rectangle when pressing and holding on selected delegate item.
Item {
id: listItem
anchors {
top: oparent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
ListView {
id: list
anchors.fill: parent
currentIndex: -1
clip: true
model: itemModel
delegate: ItemDelegate {
MouseArea {
id: area
anchors.fill: parent
onPressAndHold: {
menu.showed = true
menu.x = mouseX
menu.y = mouseY
}
}
}
boundsBehavior: Flickable.StopAtBounds
CustomMenu {
id: menu
z: 100
parent: list
model: menuModel
}
}
}
Item {
id: listItem
anchors {
top: oparent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
ListView {
id: list
anchors.fill: parent
currentIndex: -1
clip: true
model: itemModel
delegate: ItemDelegate {
MouseArea {
id: area
anchors.fill: parent
onPressAndHold: {
menu.showed = true
menu.x = mouseX
menu.y = mouseY
}
}
}
boundsBehavior: Flickable.StopAtBounds
CustomMenu {
id: menu
z: 100
parent: list
model: menuModel
}
}
}
To copy to clipboard, switch view to plain text mode
In the code above, it returns only the mouse coordinates on selected item that is why the menu always showed on top part of the Item.
When I tried putting mousearea on listItem, the ListView will not work.
Please advice, thanks.
Bookmarks