Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.3.2
-
None
Description
As shown by the following piece of code, that ends up with the children sorted in descending order. Using the commented line to set the sort indicator is the correct, but unintuitive solution.
#include "dialogimpl.h"
#include <QtGui>
DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
char buff[256];
treeWidget->setSortingEnabled(TRUE);
QTreeWidgetItem *root = new QTreeWidgetItem( QStringList(QString("TreeWidgetExample")));
treeWidget->addTopLevelItem(root);
root->setExpanded ( TRUE ) ;
treeWidget->headerItem ()->setText(0,"");
//Event Chance
sprintf(buff,"Event Chance");
QTreeWidgetItem* itemEC = new QTreeWidgetItem( QStringList(buff));
itemEC->setText(0, itemEC->text(0) +" (DRY)");
root->addChild(itemEC);
itemEC->setExpanded(TRUE);
//Scenari
for(int k=7;k>=1;k--)
//Mean
sprintf(buff,"Mean ");
QTreeWidgetItem* itemS = new QTreeWidgetItem( QStringList(buff));
root->addChild(itemS);
root->sortChildren ( 0, Qt::AscendingOrder);
//treeWidget->header()->setSortIndicator(0, Qt::AscendingOrder);
}