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. QSqlQueryModel to display the result of several queries in one qtableview
Forum Updated to NodeBB v4.3 + New Features

QSqlQueryModel to display the result of several queries in one qtableview

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 292 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.
  • S Offline
    S Offline
    Shamma
    wrote on last edited by
    #1

    I have three tables, table 1 connected to 2, and table 2 connected to 3 all tables has the same number of columns . so am using the QSqlQueryModel to display the results. is there a way to add a rows from different queries in one model and display it in one qtableview?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deleted385
      wrote on last edited by
      #2

      Does union work?

      SELECT ...
      UNION ALL
      SELECT ...
      UNION ALL
      SELECT ...
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        Shamma
        wrote on last edited by
        #3

        unfortunately, no because the table are as a tree. each table related to just one.

        jsulmJ 1 Reply Last reply
        0
        • S Shamma

          unfortunately, no because the table are as a tree. each table related to just one.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Shamma said in QSqlQueryModel to display the result of several queries in one qtableview:

          unfortunately, no because the table are as a tree. each table related to just one.

          What does this mean? A SQL table is not a tree, its a table.
          The correct way to join data from several tables in SQL is what @Emon-Haque proposed. But you answer to him is completely unclear...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            Maybe a concrete example of what you want to achieve would be good here.

            From your initial post I was thinking you needed QConcatenateTablesProxyModel but now I'm confused

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            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