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
Forum Updated to NodeBB v4.3 + New Features

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.
  • T Offline
    T Offline
    Thank You
    wrote on 1 Dec 2020, 15:01 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

    J 1 Reply Last reply 1 Dec 2020, 16:34
    0
    • T Thank You
      1 Dec 2020, 15:01

      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

      J Offline
      J Offline
      JonB
      wrote on 1 Dec 2020, 16:34 last edited by JonB 12 Feb 2020, 10:36
      #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.]

      T 1 Reply Last reply 2 Dec 2020, 03:51
      2
      • J JonB
        1 Dec 2020, 16:34

        @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.]

        T Offline
        T Offline
        Thank You
        wrote on 2 Dec 2020, 03:51 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

        J 1 Reply Last reply 2 Dec 2020, 07:03
        0
        • T Offline
          T Offline
          Thank You
          wrote on 2 Dec 2020, 03:52 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
          • T Thank You
            2 Dec 2020, 03:51

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

            J Offline
            J Offline
            JonB
            wrote on 2 Dec 2020, 07:03 last edited by JonB 12 Feb 2020, 07:05
            #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

            1/5

            1 Dec 2020, 15:01

            • Login

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