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 theEditStrategy
property does. -
Hi,
What do you mean by natively ? It's not really clear.
-
Thanks.
I mean: if you use theEditStrategy
feature, you don't need aQPushButton
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 aQToolButton
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