ListModel from SQL. Relation one to many



  • 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"
    }
    ]
    }
    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.