Hellow again!
I modificated my code and all must work right:
@void RizekFaster::traverseNode(const QDomNode& node, QModelIndex& index)
{
int count = 0;
QDomNode domNode = node.firstChild();
while(!domNode.isNull())
{
if(domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if(!domElement.isNull())
{
if(domElement.tagName() == "folder")
{
itemModel->insertRow(count,index);
QModelIndex newIndex = itemModel->index(count,0,index);
itemModel->setData(newIndex,domElement.attribute("name",tr("New folder")));
count++;
traverseNode(domElement,newIndex);
}
if(domElement.tagName() == "item")
{
itemModel->insertRow(count,index);
QModelIndex newIndex = itemModel->index(count,0,index);
itemModel->setData(newIndex,domElement.text()); //This cant work in the folders
count++;
}
}
}
domNode = domNode.nextSibling();
}
}@
But in this @QModelIndex newIndex = itemModel->index(count,0,index);@
When index is valid and count is valid(0 when there is no 0 rows in this index's table, and 1 when there is 1 rows in the index's table) the newIndex is not valid. Why is it happened?