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. [solved] qtreeview edit last inserted item
Forum Updated to NodeBB v4.3 + New Features

[solved] qtreeview edit last inserted item

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.0k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    broadpeak
    wrote on last edited by
    #1

    I have a QTreeView.
    In this view there are groups with some items in it.
    When I create a new group, I'd like to "select" (highlight) this last inserted item.
    What is the modelindex of this item?
    How can I solve this?

    (
    [This is similar in Windows when you create a new folder]

    What I exactly want:
    create new item (last inserted item...) with a predefined arbitrary name ("group 001")
    select it (programatically)
    call a delegate's createeditor() method on this item ("simulate" F2 edit key)
    edit (rename...)
    save (ENTER)
    )

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      If i understand you correctly
      "http://doc.qt.digia.com/stable/itemviews-editabletreemodel.html":http://doc.qt.digia.com/stable/itemviews-editabletreemodel.html
      can be helpful for you. Add current lines in insertRow() method:
      @QModelIndex child = model->index(index.row()+1, 0, index.parent());
      view->selectionModel()->setCurrentIndex(child,QItemSelectionModel::SelectCurrent);
      view->edit(child);@

      1 Reply Last reply
      0
      • B Offline
        B Offline
        broadpeak
        wrote on last edited by
        #3

        YEEEESSSSSS...
        This was EXACTLY the solution :)
        Thank you!

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          I am glad to hear it :)

          1 Reply Last reply
          0

          • Login

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