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. Two or more model on the same modelview
Qt 6.11 is out! See what's new in the release blog

Two or more model on the same modelview

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 819 Views 1 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.
  • P Offline
    P Offline
    plinioandrade
    wrote on last edited by
    #1

    Let’s say I have a table for customer and other one for address and the address table has some fields like ‘zip_code’, ‘city’,‘state’ and so on and the customer table has a field called 'addresd_id' which is a foreign key for the table address (the id field). What should I do if I want to show a TableView with the complete information about customers (including the all address table fields)? The QSqlRelationalTableModel just allow me to link a foreign key to ONE field on other table but in fact I want to link one foreign key to the complete row in other table and show all fields of that table. Does someone have a solution?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Resurrection
      wrote on last edited by
      #2

      Unless you need editing QSqlQueryModel. If you need editing you will have to sub-class it as the relational model does not suit your needs.

      Secrets are power.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        th.thielemann
        wrote on last edited by
        #3

        Just an idee: If case you can extend the database, create a view in the database from both address table and customer table. And than use this view in the model.

        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