PDA

View Full Version : QTreeWidget selection



Arthur
9th March 2007, 13:37
Hello,

I want a QTreeWidget with multiple selection (with CTRL keys as QAbstractItemView::ExtendedSelection). Multiple selecting items should turn multiple items blue. Like the pic shown in this thread:
http://www.qtcentre.org/forum/f-qt-programming-2/t-selecting-lots-of-treewidget-itemns-slow--2662.html

Howver, I set my tree to Selection: QAbstractItemView::ExtendedSelection, SelectionBehavior to: QAbstractItemView::SelectRows

First: I only see a rubberband around the selected column and second I cannot multiple select rows.

What am I doing wrong?

Arthur

guilugi
9th March 2007, 15:05
Sorry, I misread your post :)

Can you post a sample of code (compilable ?)

Arthur
9th March 2007, 16:05
ui.tree->setColumnCount(3);
QStringList labels;
labels << tr("Aap") << tr("Noot") << tr("Mies");
ui.tree-->setHeaderLabels(labels);

for(int i = 0; i < 10; ++i)
{
QTreeWidgetItem * pItem = new QTreeWidgetItem(ui.tree);
pItem->setText(0, "Aap");
pItem->setText(1, "Noot");
pItem->setText(2, "Mies");
}


In fact, this tree works fine. I have multiple row selection and selected rows turn blue...
however if I make items editable:



pItem->setFlags(Qt::ItemIsEditable);


I only see a rubberband around the column I want to change and no selected row. Why?
Also I cannot multiple select rows...

snooker
21st March 2007, 05:53
ui.tree->setColumnCount(3);
QStringList labels;
labels << tr("Aap") << tr("Noot") << tr("Mies");
ui.tree-->setHeaderLabels(labels);

for(int i = 0; i < 10; ++i)
{
QTreeWidgetItem * pItem = new QTreeWidgetItem(ui.tree);
pItem->setText(0, "Aap");
pItem->setText(1, "Noot");
pItem->setText(2, "Mies");
}


In fact, this tree works fine. I have multiple row selection and selected rows turn blue...
however if I make items editable:



pItem->setFlags(Qt::ItemIsEditable);


I only see a rubberband around the column I want to change and no selected row. Why?
Also I cannot multiple select rows...
Try this.

pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);

When You write
pItem->setFlags(Qt::ItemIsEditable); you clean all previus flags.