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. load data from database to tree view
Forum Updated to NodeBB v4.3 + New Features

load data from database to tree view

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.1k 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.
  • N Offline
    N Offline
    Nevez
    wrote on 9 Feb 2022, 12:56 last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nevez
      wrote on 9 Feb 2022, 14:36 last edited by
      #2

      can anyone help ?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 9 Feb 2022, 14:50 last edited by
        #3

        @Nevez said in load data from database to tree view:

        can anyone help ?

        Why so impatient?
        The treeview you show above is not that easy. You have to build your tree model by your own.

        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
        • N Offline
          N Offline
          Nevez
          wrote on 10 Feb 2022, 08:22 last edited by
          #4

          @Christian-Ehrlicher I know that too. However, I have no idea how to do this. Can you give some hint

          J 1 Reply Last reply 10 Feb 2022, 08:34
          0
          • N Nevez
            10 Feb 2022, 08:22

            @Christian-Ehrlicher I know that too. However, I have no idea how to do this. Can you give some hint

            J Offline
            J Offline
            JonB
            wrote on 10 Feb 2022, 08:34 last edited by JonB 2 Oct 2022, 08:41
            #5

            @Nevez
            To create a hierarchical parent-child tree model you need two things from your data:

            • Some unique id column for every row.
            • A parent_id column in every row, whose value is the unique id of some other row which is its parent.

            You could store these as columns in your actual database TABLEs, or via VIEWs you create on the tables, or via your SELECT statement, as suitable. You can also impose a suitable QAbstractProxyModel on top of your SQL model to present the data hierarchically to the QTreeView.

            Then you have the information to populate your data model/table view correspondingly.

            I have not looked through it, but starting from Googling, say, qt qsqldatabase qtreeview, there is
            https://stackoverflow.com/questions/53418180/populate-qtreeview-as-parent-and-child-nodes-from-database
            https://forum.qt.io/topic/83982/populate-qtreeview-from-sql
            https://www.qtcentre.org/threads/23698-how-to-display-QSqlQueryModel-in-QTreeView

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Nevez
              wrote on 10 Feb 2022, 08:40 last edited by
              #6

              Thanks for your interest, I'll look into them :)

              1 Reply Last reply
              0

              1/6

              9 Feb 2022, 12:56

              • Login

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