Hi there, I'm doing things like this:
theTree->addTopLevelItem(newItem);
theTree->addTopLevelItem(newItem);
// etc. etc....
// after all items have been added, we then call the following within the same function:
theTree->sortItems(0, Qt::AscendingOrder);
QTreeWidgetItem *newItem = new QTreeWidgetItem("Foo");
theTree->addTopLevelItem(newItem);
newItem = new QTreeWidgetItem("Bar");
theTree->addTopLevelItem(newItem);
// etc. etc....
// after all items have been added, we then call the following within the same function:
theTree->sortItems(0, Qt::AscendingOrder);
To copy to clipboard, switch view to plain text mode
Of course things are a little more complicated than that, with multiple columns etc. But this is how things are added, sorted, and in the order that it happens. I wouldn't think it could be any simpler than this!
Running Qt 4.6.2 if that makes any difference.
Bookmarks