Hello, i have to add a node in QTreeWidget.
My QTreeWidget before this operation is:
voice1
voice2
|__subvoice1
i want to add a child to subvoice1:
voice1
voice2
|__subvoice1
|__ subsubvoice1
this's the code:
// disconnect signal
ui.twmConfigtreeWidget->blockSignals ( true );
QList<QTreeWidgetItem *> connectionItemsList;
nodeNameString = "voice2";
connectionItemsList = ui.twmConfigtreeWidget->findItems( nodeNameString , Qt::MatchContains , 0 );
for ( int i = 0; i < connectionItemsList.size(); i++ )
{
QList<QTreeWidgetItem *> connectionsChildren = connectionItemsList.at( i )->takeChildren();
for ( int k = 0; k < connectionsChildren.size(); k++ )
{
if ( connectionsChildren.at( i )->text( 0 ) == "subvoice1" )
{
twmQTreeWidgetRDPNewConnection->setText( 0 , "subsubvoice1" );
connectionsChildren.at( i )->insertChild( 0 , twmQTreeWidgetRDPNewConnection );
}
}
}
// connect signal
ui.twmConfigtreeWidget->blockSignals ( false );
// disconnect signal
ui.twmConfigtreeWidget->blockSignals ( true );
QList<QTreeWidgetItem *> connectionItemsList;
QString nodeNameString;
nodeNameString = "voice2";
connectionItemsList = ui.twmConfigtreeWidget->findItems( nodeNameString , Qt::MatchContains , 0 );
for ( int i = 0; i < connectionItemsList.size(); i++ )
{
QList<QTreeWidgetItem *> connectionsChildren = connectionItemsList.at( i )->takeChildren();
for ( int k = 0; k < connectionsChildren.size(); k++ )
{
if ( connectionsChildren.at( i )->text( 0 ) == "subvoice1" )
{
QTreeWidgetItem * twmQTreeWidgetRDPNewConnection = new QTreeWidgetItem ();
twmQTreeWidgetRDPNewConnection->setText( 0 , "subsubvoice1" );
connectionsChildren.at( i )->insertChild( 0 , twmQTreeWidgetRDPNewConnection );
}
}
}
// connect signal
ui.twmConfigtreeWidget->blockSignals ( false );
To copy to clipboard, switch view to plain text mode
but it does not work...my tree is always the same...any hint?
Bookmarks