Qtreewidget not updating data
Hi All
I'm writing an application where i'm using tree widget. if i click on the treewidget an input dialog is poping up and asking to enter a string. i need to update that string in treewidget. Below is my code. But its not updating in tree widget. Can ny body help me.
Code:
bool b;
tr( "New name" ),
tr( "Please enter the name " ),
QLineEdit::Normal, tr
( "New classroom" ),
&b
);
if(b && !name.isEmpty())
{
strlist.push_back(classroom_name);
m_name.append(&temptreelst); //QList<QTreeWidgetItem *> m_name is to colect the list of names and amember variable
ui->treeWidget->addTopLevelItem(&temptreelst);
ui->treeWidget->expandAll();
}
Thank u all.
Re: Qtreewidget not updating data
First, in your code you don't use the asked string name. Second, create your QTreeWidgetItem on the heap, because else it gets deleted after the scope.
Re: Qtreewidget not updating data
Quote:
Originally Posted by
Lykurg
First, in your code you don't use the asked string
name. Second, create your
QTreeWidgetItem on the heap, because else it gets deleted after the scope.
thank u for quick response. there was ll mistake in the code. Below i've posted the code.
Code:
bool b;
tr( "New name" ),
tr( "Please enter the name " ),
QLineEdit::Normal, tr
( "New classroom" ),
&b
);
if(b && !name.isEmpty())
{
strlist.push_back(name );
m_name.append(&temptreelst); //QList<QTreeWidgetItem *> m_name is to colect the list of names and amember variable
ui->treeWidget->addTopLevelItem(&temptreelst);
ui->treeWidget->expandAll();
}
temptreelst is QTreeWidgetItem object. But still its nt updating.:(