Reputation: 307
I have a basic QTableView displaying data from an SQLite table with QSqlTableModel.
Data entry is done by the parent dialog having a number of widgets representing the field data and an "Add" button. Data removal is done via a "Remove selected rows" button.
Everything is very functional but I find it incredibly clunky and want to try a Better Way.
Ideally, I would like an empty row in the view into which the user can simply begin typing their data. At the end of each row a button to delete that specific row (kind of like the vertical headers but with a push button instead of row numbers).
I think this may be achievable with sub-classing QTableView, but the idea of having to repaint everything is a little daunting...
Does anyone have advice on how I could go about this, maybe using Delegates (admittedly something I have not used before) or another simpler method that I have overlooked??
Upvotes: 0
Views: 825
Reputation: 2829
From what you describe you shouldn't have to worry about repainting anything. Simply you can add a QButton
in the last cell of row. There are several answers/articles on adding a button to a QTableView
:
Secondly, with allowing a user to add a row directly read this article sections on making the model editable and inserting/remove rows.
Upvotes: 1