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. Using QTreeView to show catagories / tags
Forum Updated to NodeBB v4.3 + New Features

Using QTreeView to show catagories / tags

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 660 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.
  • P Offline
    P Offline
    Phill
    wrote on last edited by
    #1

    I have a data structure where each item can have a number of tags. What I would like to do is use a QTreeView to list each tag, upon expanding each individual tag, the tree view will show the items identified with this.

    The problem comes when implementing the parent method, there is no way to know which is the parent index the model is referring to.

    raven-worxR VRoninV 2 Replies Last reply
    0
    • P Phill

      I have a data structure where each item can have a number of tags. What I would like to do is use a QTreeView to list each tag, upon expanding each individual tag, the tree view will show the items identified with this.

      The problem comes when implementing the parent method, there is no way to know which is the parent index the model is referring to.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Phill
      each QModelIndex can have a internal pointer. This can be any data structure you like. This can be used to identify your specific node.
      See the simple tree model example.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • P Phill

        I have a data structure where each item can have a number of tags. What I would like to do is use a QTreeView to list each tag, upon expanding each individual tag, the tree view will show the items identified with this.

        The problem comes when implementing the parent method, there is no way to know which is the parent index the model is referring to.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @Phill said in Using QTreeView to show catagories / tags:

        I have a data structure

        Is this "data structure" already a QAbstractItemModel?
        If the answer is no then just fill in a QStandardItemModel manually with your data. no need to reimplement a model.
        If the answer is yes then you need a QAbstractProxyModel subclass. I'm actually working on this proxy but it's not easy. I'll update this post once I implemented it

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        1

        • Login

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