QTreeWidget editItem()
Unsolved
General and Desktop
-
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" -
Hi,
Where are you calling that qDebug ?
-
@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