I am trying to build a tree in a way that I can insert the element where I want. This is my tree in its initial stage:
+Project
+--Version 1.0
+--Version 2.0
Now, let's suppose I made a Version 1.1 and I would like to add it at the location beetween Version 1.0
and Version 2.0
. Like:
+Project
+--Version 1.0
+--Version 1.1
+--Version 2.0
I have tried to add it using insertChild ( http://doc.qt.digia.com/4.7-snapshot/qtreewidgetitem.html#insertChild ) but the item does not get created in the tree. This is the code:
void VersionGuiElements::createGuiElements(QTreeWidgetItem* projectItem, int idxAfter)
{
QTreeWidgetItem* versionItem = new QTreeWidgetItem(0, QStringList(QString("Version ") + m_version->getVersionText())) ;
if(idxAfter == -1)
{
projectItem->addChild(versionItem);
}
else
{
projectItem->insertChild(idxAfter, versionItem);
}
}
but nothing gets inserted in the tree... any idea what am I doing wrongly?