PDA

View Full Version : QTreeWidget nextSibling()



user_mail07
21st August 2008, 19:21
Q3ListView nextsibling ()method in QTreeWidget.

I am process of coverting Q3ListView and Q3ListItemView to QTreeWidget and QTreeWidgetItem recursively. But I can not find equivalent nextSibling( ) method in QTreeWidget. How do I iterate for next sibling?
CCheckListTreeItem is Q3CheckListItem
m_pListView is Q3ListView and now it is QTreeWidget


CCheckListTreeItem * pChild = (CCheckListTreeItem*) m_pListView ->firstChild();

while(pChild)
{
if(pChild->isOn())
strListIDS->append(pChild->text());
pChild = (CCheckListTreeItem*)pChild->nextSibling();
}

wysota
21st August 2008, 19:44
QTreeWidgetItem *current = ...;
QTreeWidgetItem *parent = current->parent();
QTreeWidgetItem *nextSibling;
if(parent){
nextSibling =parent()->child(parent->indexOfChild(current)+1);
else {
QTreeWidget *treeWidget = current->treeWidget();
nextSibling = treeWidget->topLevelItem(treeWidget->indexOfTopLevelItem(current)+1);
}

Wasn't that hard, was it? Please at least look at available methods for all the related classes before asking such questions...