Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to rename a child with only parent index known in a treeview ?

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

Scheduled Pinned Locked Moved Solved General and Desktop
qtreeviewindexparentchild
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ratzz
    wrote on 20 Feb 2016, 14:19 last edited by
    #1

    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?

    --Alles ist gut.

    K 1 Reply Last reply 20 Feb 2016, 14:28
    0
    • R Ratzz
      20 Feb 2016, 14:19

      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?

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 20 Feb 2016, 14:28 last edited by
      #2

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

      Kind regards.

      Read and abide by the Qt Code of Conduct

      R 1 Reply Last reply 22 Feb 2016, 04:34
      1
      • K kshegunov
        20 Feb 2016, 14:28

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

        Kind regards.

        R Offline
        R Offline
        Ratzz
        wrote on 22 Feb 2016, 04:34 last edited by
        #3

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

        --Alles ist gut.

        1 Reply Last reply
        0

        2/3

        20 Feb 2016, 14:28

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved