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

QSqlQueryModel: how to insert column



  • Hi,

    I have a TableView and I get the data from the database with a QSqlQueryModel. This works; the data is displayed.
    Now I want to add an additional column automatically (not: "insertColumns(0,1)" in the mainwindow.cpp). I know, this will not insert the column in the database. It should be inserted only in the view.

    I only found out how to add a column at the end:

    int subclass::columnCount(const QModelIndex &parent) const
    {
        return QSqlQueryModel:: columnCount(parent) +1;
    
    }
    

    However, I want the the new column at the beginning of the table.
    How can I do this?

    Thanks


  • Lifetime Qt Champion

    Hi,

    Use the KDE's KExtraColumnProxyModel.


Log in to reply