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. ListModel from SQL. Relation one to many

ListModel from SQL. Relation one to many

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.7k 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.
  • V Offline
    V Offline
    VlastV
    wrote on last edited by
    #1

    Hello,

    There are two tables, user and group.
    One to many relationship: group.id = user.group_id.

    How do I get out of QSqlQueryModel model similar to:

    @
    ListModel {
    ListElement {
    group_id: "12"
    name: "Admin"
    users: [
    ListElement {
    user_id: "1"
    name: "test1"
    },
    ListElement {
    user_id: "2"
    name: "test2"
    },
    ListElement {
    user_id: "3"
    name: "test3"
    }
    ]
    }
    ListElement {
    group_id: "223"
    name: "Staff"
    users: [
    ListElement {
    user_id: "5"
    name: "staff1"
    }
    ]
    }
    }@

    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