QSqlTableModel and QTableView edit cell of a database query



  • Hello,
    I need a lot of database editable grids in my GUI. In Qt its seem very complicated compared to Microsoft Access. (Access is not a really an option of course.)
    In Access I can edit cells in a TableView of a query without an further work.
    I found that it works in a QSqlTableModel only with simple querys which are 1:1 relation to a table. select * from table -> define qrytable in a DB.

    But when make a bit more complicated query and join some an other Tables, the editing seen work first - the cell takes the new value - but the are not really stored in the database.

    I there an easy way to edit values of a query in a QTableView ?


  • Qt Champions 2016

    @Andy314
    You may want to try QSqlRelationTableModel instead.

    In Qt its seem very complicated compared to Microsoft Access.

    Sure, Qt is a library for one of the most complex programming languages out there, while Access is made to be used as an Office supplement. Complexity scales about the same as flexibility and performance, so I suppose it's fair to say Qt (and C++ by extension) is somewhat complicated.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.