
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.
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();
}
bool b;
QString name = QInputDialog::getText( this,
tr( "New name" ),
tr( "Please enter the name " ),
QLineEdit::Normal, tr( "New classroom" ), &b);
if(b && !name.isEmpty())
{
QStringList strlist;
strlist.push_back(name );
QTreeWidgetItem temptreelst(strlist);
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();
}
To copy to clipboard, switch view to plain text mode
temptreelst is QTreeWidgetItem object. But still its nt updating.
Bookmarks