Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Editable TreeView
Forum Updated to NodeBB v4.3 + New Features

Editable TreeView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 2.4k Views 2 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.
  • K Offline
    K Offline
    krojew
    wrote on last edited by
    #1

    Hi,
    I'm using TreeView to display some tree data with multiple columns, and I wish to make some of them editable. And I stumbled upon two problems:

    • there doesn't seem to be a way to select different delegates for different columns
    • even if I set e.g. TextField as the delegate, any edits do not seem to propagate back to the model

    Is this even doable?

    m.sueM 1 Reply Last reply
    0
    • K krojew

      Hi,
      I'm using TreeView to display some tree data with multiple columns, and I wish to make some of them editable. And I stumbled upon two problems:

      • there doesn't seem to be a way to select different delegates for different columns
      • even if I set e.g. TextField as the delegate, any edits do not seem to propagate back to the model

      Is this even doable?

      m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi @krojew

      You can set different delegates to different columns with the function setItemDelegateForColumn. You will use this function only for delegates you implement yourself, though. The standard delegates should work on their own. You should verify (set a breakpoint and check) that the setData virtual function of your model actually changes the data of your model after editing (parameter role = Qt::EditRole).

      -Michael.

      K 1 Reply Last reply
      0
      • m.sueM m.sue

        Hi @krojew

        You can set different delegates to different columns with the function setItemDelegateForColumn. You will use this function only for delegates you implement yourself, though. The standard delegates should work on their own. You should verify (set a breakpoint and check) that the setData virtual function of your model actually changes the data of your model after editing (parameter role = Qt::EditRole).

        -Michael.

        K Offline
        K Offline
        krojew
        wrote on last edited by
        #3

        @m.sue thanks, I'll try that.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          krojew
          wrote on last edited by
          #4

          Coming back, it seems the typical qml edit items do not call setData() or I'm doing something wrong. Also, there is no setItemDelegateForColumn method for TreeView.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MTOLANI
            wrote on last edited by
            #5

            Hi,

            Any solution to this?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxwell31
              wrote on last edited by
              #6

              Maybe this can help:
              https://forum.qt.io/topic/89143/help-with-qml-tableview/5

              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