How to select more than one delegates in listview
-
Hi all,
i have a listview with readonly text delegates, how can i visually select more than one delegates by pressing and moving the mouse over multiple delegates? E.g. there are multiple chat messages and i want to select some of them to be able to copy them. Is there any way to do that?Thanks in advance.
-
Does this (https://stackoverflow.com/questions/38438235/multiple-items-selection-from-listview) answer your question?
-
@jd42 why do you want to select more than one delegate? Do you want to delete particular or group of index from list view or you want to copy that index?
First of all you have to implement Pressandhold and Onclick functionality on mouseArea and specify z=-1
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls 2.1import "Utilitiesforarray.js" as Utilsarray
property bool flag: false
MouseArea
{
id:mouseareaforselecting
anchors.fill: parent
z:-1
onPressAndHold:
{
//initially flag becomes flase, after PressandHold the flag becomes true
if(flag===false)
{
patientdetailslist.currentIndex=index
rectfordelegate.color="sky blue"
flag=true;
Utilsarray.pushIndex(index); //storing index in array, i have method called pushIndex in Utilitiesforarray.js file
}
}
//now you can select how many delegates you want
onClicked:
{
if(flag===true)
{
//store the index values into JavaScript array
}
else
{
//do your stuff
}
}