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. QSqlQueryModel: how to insert column
Forum Updated to NodeBB v4.3 + New Features

QSqlQueryModel: how to insert column

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 197 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.
  • M Offline
    M Offline
    Mark58
    wrote on last edited by
    #1

    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

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

      Hi,

      Use the KDE's KExtraColumnProxyModel.

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

      1 Reply Last reply
      3

      • Login

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