Set it with the following parameters:
QAbstractItemView.SelectionMode.MultiSelection: Multiple selection (without pressing CTRL)
QAbstractItemView.SelectionMode.ExtendedSelection: Multiple selection (hold down CTRL, select one item at a time)
QAbstractItemView.SelectionMode.ContiguousSelection: Multiple selection (select multiple items at a time, which is equivalent to holding shift-select files under window)
Usage:
Nodetreewdiget->setselectionmode (qabstractitemview::extendedselection);
The selected items are then obtained by qlist<qtreewidgetitem*> selecteditemlist = This->selecteditems ().
int flag = qmessagebox::warning (THIS,TR ("Warning"), QString ("Data delete will not be recoverable!") "), Qmessagebox::yes,qmessagebox::no);
if (flag = = Qmessagebox::yes)
{
foreach (Qtreewidgetitem * pitem, Selecteditemlist)//traversal-by-delete
{
Cvecdisplayobjectcommand::removeobjectcommand (Getosgobject (Pitem)->getpaiobject ());//Real Delete action
}
}
(a blog will be published later Qtreewidget series---qtreewidget node renaming and several copies of copy cut)
Qtreewidget Series---qtreewidget nodes for multiple selection