mattia
6th December 2007, 08:30
Hello, i have a problem with treeWidget.
I'd like to create a treeWidget and i want that all the treeWidget nodes areexpanded.
I have tried with this code, but it doesn.'t work.
bool main::setupTreeView ( QTreeWidget * thetwmTreeWidget )
{
QList<QTreeWidgetItem *> items;
if ( listtwmConfigPool.size() != 0 )
{
for ( int i = 0; i < myObject.size() ; i++ )
{
QTreeWidgetItem * tempQTreeWidgetItem = new QTreeWidgetItem ();
tempQTreeWidgetItem->setText ( 0 , myObject.getName() );
tempQTreeWidgetItem->setExpanded( true );
qDebug() << tempQTreeWidgetItem->isExpanded(); // it's false...why?
items.append ( tempQTreeWidgetItem );
for ( int i = 0; i < myObjectParent.size(); i++ )
{
QTreeWidgetItem * tempQTreeWidgetItemParent = new QTreeWidgetItem ( tempQTreeWidgetItem );
tempQTreeWidgetItemParent->setText ( 0 , myObjectParent.getName() );
items.append ( tempQTreeWidgetItemParent );
}
}
thetwmTreeWidget->setColumnCount (1);
thetwmTreeWidget->insertTopLevelItems (0, items);
}
return TRUE;
}
thanks
I'd like to create a treeWidget and i want that all the treeWidget nodes areexpanded.
I have tried with this code, but it doesn.'t work.
bool main::setupTreeView ( QTreeWidget * thetwmTreeWidget )
{
QList<QTreeWidgetItem *> items;
if ( listtwmConfigPool.size() != 0 )
{
for ( int i = 0; i < myObject.size() ; i++ )
{
QTreeWidgetItem * tempQTreeWidgetItem = new QTreeWidgetItem ();
tempQTreeWidgetItem->setText ( 0 , myObject.getName() );
tempQTreeWidgetItem->setExpanded( true );
qDebug() << tempQTreeWidgetItem->isExpanded(); // it's false...why?
items.append ( tempQTreeWidgetItem );
for ( int i = 0; i < myObjectParent.size(); i++ )
{
QTreeWidgetItem * tempQTreeWidgetItemParent = new QTreeWidgetItem ( tempQTreeWidgetItem );
tempQTreeWidgetItemParent->setText ( 0 , myObjectParent.getName() );
items.append ( tempQTreeWidgetItemParent );
}
}
thetwmTreeWidget->setColumnCount (1);
thetwmTreeWidget->insertTopLevelItems (0, items);
}
return TRUE;
}
thanks