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. TreeView Content from 2 XML Files

TreeView Content from 2 XML Files

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

    Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?

    Christian EhrlicherC JonBJ 2 Replies Last reply
    0
    • Q QtisHard

      Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @QtisHard said in TreeView Content from 2 XML Files:

      Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?

      Yes because you create the model and therefore can do whatever you want.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • Q QtisHard

        Is it possible to create the Parent Node in TreeView from one XML File and add the children from another XML File?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @QtisHard
        As @Christian-Ehrlicher says, but note it's because you aren't actually having the QTreeView's model be the XML, only whatever you did with it to get it into some model you are using. If you used QDomDocument as your internal model you wouldn't be able to add nodes from one XML document directly into a different one.

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

          Yes I used QDomDocument for creating the model that I am bounding to the treeview.

          https://forum.qt.io/topic/138614/treeview-content-with-common-parent-and-different-children
          This is what I am trying to achieve.

          I thought if I put the values in different XML files it might work out. However it seems that it wont.

          Please guide me as to how I should proceed with this

          JonBJ 1 Reply Last reply
          0
          • Q QtisHard

            Yes I used QDomDocument for creating the model that I am bounding to the treeview.

            https://forum.qt.io/topic/138614/treeview-content-with-common-parent-and-different-children
            This is what I am trying to achieve.

            I thought if I put the values in different XML files it might work out. However it seems that it wont.

            Please guide me as to how I should proceed with this

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @QtisHard
            I only know from experience with XML documents. You have to import nodes from a different XML document if you want them, which is effectively copying them, not just using/pointing to them. For QDomDocument I would expect to have to use QDomNode QDomDocument::importNode(const QDomNode &importedNode, bool deep), which I think you should read/apply.

            This is all supposing you want a valid, full QDocument for your model. As @Christian-Ehrlicher says, since the QTreeView only actually recognises/uses a QAbstractItemModel you can do what you like behind the scenes to supply that in your own way from multiple XML files (not one QDomDocument) if you wish.

            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