Ok, sorry for being difficult to understand, the code is this:
for(int i=2; i < a; i++){
//code here...
for(int j=2;j<dir1_count;j++){
//code here...
//here adding a child to parnt...
parnt->addChild(child1);
}
//after adding the children to the parnt I insert the parnt to the list
qDebug() << parnt->text(i-2);
list.insert(i-2,parnt);
}
//finally, i insert the list to the treewidget...
ui->treeWidget->addTopLevelItems(list);
for(int i=2; i < a; i++){
//code here...
for(int j=2;j<dir1_count;j++){
//code here...
//here adding a child to parnt...
parnt->addChild(child1);
}
//after adding the children to the parnt I insert the parnt to the list
qDebug() << parnt->text(i-2);
list.insert(i-2,parnt);
}
//finally, i insert the list to the treewidget...
ui->treeWidget->addTopLevelItems(list);
To copy to clipboard, switch view to plain text mode
The output of qDebug() as I said to the first post is as I expected to be (different month each time) but in the treewidget there is inserted the same month (the first one) without an obvious reason. This is the same code but it also outputs the list's contents:
qDebug() << "Parnt at " << i-2 << " has '" << parnt->text(i-2) << "'";
list.insert(i-2,parnt);
qDebug() << " List at " << i-2 << " has '" << list.at(i-2)->text(0) << "'";
qDebug() << "Parnt at " << i-2 << " has '" << parnt->text(i-2) << "'";
list.insert(i-2,parnt);
qDebug() << " List at " << i-2 << " has '" << list.at(i-2)->text(0) << "'";
To copy to clipboard, switch view to plain text mode
So, by running this code by outputing the contents of the 'list', the output is:
Parnt at 0 has ' "2011 May" ' <- As expected
List at 0 has ' "2011 May" ' <- As expected
Parnt at 1 has ' "2011 October" ' <- As expected
List at 1 has ' "2011 May" ' <- No comment :/
Parnt at 0 has ' "2011 May" ' <- As expected
List at 0 has ' "2011 May" ' <- As expected
Parnt at 1 has ' "2011 October" ' <- As expected
List at 1 has ' "2011 May" ' <- No comment :/
To copy to clipboard, switch view to plain text mode
Which i find weird...
Obviously, the error is while inserting the 'parnt' into the 'list' or while using addTopLevelItems()
Thx in advance again...
Bookmarks