Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to load enter data in qtable view?
Nayan Thapa Magar last edited by
This post is deleted!
MarKS last edited by MarKS
First thing you need is a model to add data and then you can use
QTableViewto show your data. You can use
QStandardItemModelfor now, as it is easier to handle data as a beginner.
Follow this to understand how the model works with a view.
To insert rows may be this will help you.
JonB last edited by JonB
Write your model, with columns
product name. You might use a custom model, a
QSqlTableModelif you are using an actual database. Store the numeric columns to hold numbers, not strings.
QTableViewfor the model. Alternatively, you could make it a
QTableWidget, in which the case model mentioned in #1 will already be attached to it (
QTableWidgethas its own inbuilt model).
Get that working to display whatever rows the table has.
Easiest is if you add something like
QPushButtonjust below (not inside) the table. Clicking it adds a new, blank row at the end of the table, for a new item. Or have dedicated widgets for the user to pick what he wants and a button to add that as the row. There are other ways too.
(Probably) extend the
QTableViewto allow columns Modify and Remove with their own buttons against each row.
For adding/modifying you have a choice: you can have dedicated widgets outside the table where you copy rows/do your editing, or you can make your
QTableViewallow editing in selected row, changing values inside the actual row.
That's the outline.