Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Creating custom model for QTableView



  • 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



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



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



  • @mrjj @jsulm @SGaist
    Help me guys



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


Log in to reply