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

QSqlTableModel and UI



  • Using QSqlTableModel might be useful when you have to show and edit data from an SQL table.
    Usually I add some buttons on the side of the table to allow basic functions like "add", "remove", etc...
    I just wonder if these function may be handled by the widget natively, like the EditStrategy property does.


  • Lifetime Qt Champion

    Hi,

    What do you mean by natively ? It's not really clear.



  • Check InsertProxyModel of this library if it's what you had in mind.
    Examples of useage are available here

    For the remove part I can't really see what "native" would be like



  • Thanks.
    I mean: if you use the EditStrategy feature, you don't need a QPushButton to commit the changes (or catch a signal when the user change the cell/row). But you still need buttons for add and remove rows. For me "natively" means the same thing: usually a blank row at the end allows to add a new record without using an external button. To remove a row, it would be enough a QToolButton X on the vertical header, for example.

    I'm aware I can do all this stuff by myself - and that what I usually do. I just wondered if they provided some basic UI for interact with the database (something like the "navigation toolbar" in .NET).



  • @Mark81 said in QSqlTableModel and UI:

    usually a blank row at the end allows to add a new record without using an external button

    @VRonin said in QSqlTableModel and UI:

    Check InsertProxyModel of this library if it's what you had in mind.


    @Mark81 said in QSqlTableModel and UI:

    it would be enough a QToolButton X on the vertical header

    This is nothing I've evere seen as a "standard" so yeah, you have to implement it yourself but it should be straightforward


Log in to reply