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. Working with QSqlRelationalTableModel
Qt 6.11 is out! See what's new in the release blog

Working with QSqlRelationalTableModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.3k 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.
  • Dan3460D Offline
    Dan3460D Offline
    Dan3460
    wrote on last edited by
    #1

    I have a model that comes from a Sql database which is displayed on a TableView. I need to work with some computed columns (e.i. hourSalary*hoursWork).
    I have looked around but i have not been able to understand if it possible to do this. What i want to do is the following:

    • add a column to the model
    • calculate this new column from the other two.
    • Get the total from the new column
      I know that i can do that using temporary Sql tables, but it seems to me that the model almost gives me all what i need.

    Thanks for the help

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Looks like you are looking for a proxy model based on QAbstractProxyModel.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      VRoninV 1 Reply Last reply
      2
      • Dan3460D Offline
        Dan3460D Offline
        Dan3460
        wrote on last edited by
        #3

        Thanks, I will look into it.

        1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          Looks like you are looking for a proxy model based on QAbstractProxyModel.

          Hope it helps

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @SGaist said in Working with QSqlRelationalTableModel:

          Hi,

          Looks like you are looking for a proxy model based on QAbstractProxyModel.

          Hope it helps

          More in particular KExtraColumnsProxyModel

          "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
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved