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. How to create a db and display it into a treeview? (Advice)
Forum Updated to NodeBB v4.3 + New Features

How to create a db and display it into a treeview? (Advice)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 693 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.
  • MikhailGM Offline
    MikhailGM Offline
    MikhailG
    wrote on last edited by MikhailG
    #1

    Hello!
    I can not decide or convince myself which approach I should learn or inspect.
    In genereal I have an app which has a settings page with a strcuture of a tree.
    Like:
    It is rough example of what I would like to implement.

    • car
      • speed - 20
      • weight - 100
    • bycicle
      • grils bike
        • color - red
        • color - pink
      • boys bike
        • color - black
        • color - green

    All that data I want to put into a db. Than display it and edit.

    What I have for now are TreeModel derived from QAbstractItemModel and TreeNode. Data for my TreeModel I populate manually
    like: TreeModel.nodesList.append("bike", "red") etc.
    But I would like to load the data from the db and put it into a TreeNode.
    Please put me in a right direction. Advice on how to make it would be great!
    Thank you.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      A QSqlTableModel with a QAbstractProxyModel comes to mind. The former to get the data from your database, the later to turn in into a tree structure.

      Otherwise, you can use QSqlQuery to extract the data from your database and put it in your TreeModel which is the fast and easy way.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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