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. Creating custom model for QTableView

Creating custom model for QTableView

Scheduled Pinned Locked Moved Solved General and Desktop
qt 5.12qtableview
5 Posts 2 Posters 1.1k 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.
  • Thank YouT Offline
    Thank YouT Offline
    Thank You
    wrote on last edited by
    #1

    I have made a QTableView named "task"

    Some of the data are added using QSqlQuery

    So that means there are already columns

    The thing that I want is to insert another columns with my data

    image.png

    In the table Upper table is filled using sql query

    The thing that i want is second one
    I just want to insert something after the values

    Let's make QT free or It will go forever

    TRUE AND FALSE <3

    JonBJ 1 Reply Last reply
    0
    • Thank YouT Thank You

      I have made a QTableView named "task"

      Some of the data are added using QSqlQuery

      So that means there are already columns

      The thing that I want is to insert another columns with my data

      image.png

      In the table Upper table is filled using sql query

      The thing that i want is second one
      I just want to insert something after the values

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Thank-You
      If you want to add columns/rows beyond what the SQL returns (and don't want to manipulate the query to return these extras, which is a different possibility), you need to interpose some some kind of QAbstractProxyModel between the SQL model and the QTableView.

      [EDIT Another alternative. Depending on what you mean by

      Some of the data are added using QSqlQuery

      If you are manually copying data from a query into the view's own (non-SQL) model you can add your extra rows/columns there. If you using one of the QSql... model classes you can sub-class and add your rows/columns there.]

      Thank YouT 1 Reply Last reply
      2
      • JonBJ JonB

        @Thank-You
        If you want to add columns/rows beyond what the SQL returns (and don't want to manipulate the query to return these extras, which is a different possibility), you need to interpose some some kind of QAbstractProxyModel between the SQL model and the QTableView.

        [EDIT Another alternative. Depending on what you mean by

        Some of the data are added using QSqlQuery

        If you are manually copying data from a query into the view's own (non-SQL) model you can add your extra rows/columns there. If you using one of the QSql... model classes you can sub-class and add your rows/columns there.]

        Thank YouT Offline
        Thank YouT Offline
        Thank You
        wrote on last edited by
        #3

        @JonB I want to add one row at the end of the table as show in the above picture

        Let's make QT free or It will go forever

        TRUE AND FALSE <3

        JonBJ 1 Reply Last reply
        0
        • Thank YouT Offline
          Thank YouT Offline
          Thank You
          wrote on last edited by
          #4

          @mrjj @jsulm @SGaist
          Help me guys

          Let's make QT free or It will go forever

          TRUE AND FALSE <3

          1 Reply Last reply
          0
          • Thank YouT Thank You

            @JonB I want to add one row at the end of the table as show in the above picture

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @Thank-You said in Creating custom model for QTableView:

            I want to add one row at the end of the table as show in the above picture

            Help me guys

            Already told you what you need to do. What help are you expecting? We don't write the code for you (we also have a lot of work to do!), we tell you what you need to do.

            1 Reply Last reply
            4

            • Login

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