PDA

View Full Version : Ctrl and Shift selection in QTreeWidget



npc
8th March 2007, 09:34
Hi,

I am using QTreeWidget to display the No of items using QTreeWidgetItem like this



QTreeWidgetItem* n;
n = new QTreeWidgetItem ((QTreeWidget*)0, QStringList ( strList ));
n->setFlags ( n->flags() | Qt::ItemIsUserCheckable );
n->setCheckState (0,Qt::Unchecked);


I set selectionbehaviour to QAbstractItemView::SelectItems
and selectionmode to QAbstractItemView::ExtendedSelection

Now If I select the items in treewidget using shift+arrow (or) ctrl+mouse pointer and press spacebar, the last item which is selected is checked. but i want to check all the items which are selected. How to achive this ?

I am using Qt 4.2.2/windows

Thanks
*npc*

jpn
8th March 2007, 10:12
Now If I select the items in treewidget using shift+arrow (or) ctrl+mouse pointer and press spacebar, the last item which is selected is checked. but i want to check all the items which are selected. How to achive this ?
In my humble opinion, it doesn't sound like an intuitive action to do. A common (and suggested) approach is to provide an external widget to change the check state of all selected items. Here's a thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qlistwidgetitem-checkuncheck-1951.html) worth reading.