QTreeWidget editItem()
Unsolved
General and Desktop
-
wrote on 31 Dec 2015, 20:32 last edited by
void MyTreeWidget::createChild()
{
QTreeWidgetItem* new_child = new QTreeWidgetItem();
new_child->setText(0,"Untitled Playlist");
new_child->setFlags(new_child->flags() | Qt::ItemIsEditable);
topLevelItem(1)->insertChild(0,new_child);
editItem(new_child);
}
after this function executes, the new_child should be edited now
but when i use qDebug() to it, it outputs "Untitled Playlist" -
wrote on 31 Dec 2015, 21:05 last edited by LorenceThis post is deleted!
-
Hi,
Where are you calling that qDebug ?
-
wrote on 1 Jan 2016, 12:34 last edited by Lorence 1 Jan 2016, 13:16
@SGaist
hello,
herevoid MyTreeWidget::keyPressEvent(QKeyEvent *e)
{
if ( ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) && !hasFocus() )
{qDebug() << topLevelItem(1)->child(0)->text(0); emit newChildCreated(topLevelItem(1)->child(0)->text(0)); // this one has nothing to do with tree
}
-
You might be getting the value before it has been transferred to the model
5/5