How to rename a child with only parent index known in a treeview ?



  • I am working on a QStandardItemModel with only the index of parent know how can i rename the child.
    I used setItem with parent row and column as 1 it returns 0

           Model->setItem(row,1,item);
    

    I even tried setData but it works only for parent

            ui->treeView->model()->setData(parentIndex,new_name,Qt::EditRole);
    

    How can i rename a child with only parent index known in a treeview?


  • Qt Champions 2016

    @Ratzz
    Hello,
    Retrieve the child model index first with QModelIndex::child and then set your data.

    Kind regards.



  • @kshegunov
    Thanks for your reply.
    Yes retrieving the child model via child and then setting data worked for me .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.