selectable item in listview while dragging is enable
Solved
QML and Qt Quick
-
Replace
onPressAndHold
byonPressed
should do what you want.So you will have :
onPressed: held = true
If you want to understand what they do, they just change the color of the selected Item when
held = true
.Code :
color: dragArea.held ? "lightsteelblue" : "white"
Meaning if you have trouble with this syntax:
if (dragArea.held == true) { color = "lightsteelblue" } else { color = "white" }
-
Dear @Fheanor ,
This app is just for dragging items to the other position if you hold one item for about 2 second you are be able to move the item I need this feature for my app also I need a way in which users can select one item by just on click on it.
When user click on one item I want to highlight the item to show the user the item selected now and be ready for some changes.
that's the actual problem -
@Alien So if you just click on the Item, you just have to change the color.
... MouseArea { id: dragArea property bool selected : false ... onClicked : { if(view.currentItem != null) view.currentItem.selected = false view.currentItem = dragArea selected = true } ... Rectangle { ... color: dragArea.held ? "lightsteelblue" : dragArea.selected ? "yellow" : "white" ... } } .... ListView { id: view property var currentItem: null ... }