Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, December 2007
tree items to list


Message 1 in thread

Hi All,

For storing QTreeWidget items into a QList, I used the following code,

tree->expandAll();
tree->selectAll();
QList<QTreeWidgetItem *> list = tree->selectedItems();
for (int var = 0; var < list.count(); ++var) {
      QString str = "ID: 
"+QString::number(list.value(var)->indexOfChild(list.value(var)))
            +"\tpID: 
"+QString::number(list.value(var)->parent()->indexOfChild(list.value(var)))
            +"\tTEXT: "+list.value(var)->text(0);
          
      ui.listWidget->addItem(str);
}

but I noticed that indexOfChild() always gives me -1 value, so how I can 
solve this error?!

another thing,

is this code is corrcet? I think using this way in storing is not 
practical [expandAll(), selectAll()]

-- 
 [ signature omitted ]