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. Left join on to models

Left join on to models

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k 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.
  • C Offline
    C Offline
    cultivation
    wrote on last edited by
    #1

    hi,

    I have search on a lot of qt sites/forums. But i can not find the solution how to to join 2 QSqlTableModels together.

    The models x and y can an be joined on x.nr and y.nr. table y contains extra information so i want to use a Left join. If the is for some reason no extra information the row form x is still displayed. The result needs to be a models so i can view it with a QTableView.

    On several places i read that i need to subclass QAbstractProxyModel. But how? which function need to be reimplemented?

    Does someone has an example?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bodzio131
      wrote on last edited by
      #2

      Can mentioned join be achieved by sql query? If yes then instead of implementing filtering model (QAbstractProxyModel) try to set appropriate sql query for your QSqlTableModel (see 'setQuery' methods).

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cultivation
        wrote on last edited by
        #3

        Model x is a model with data that is not committed to the database. So a join in the database cant be done. Table y contains extra information for each row from table x.

        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