How to insert new record in a QSqlRelationalTableModel
-
What happens if you manually call submit on the mapper ?
-
The same: a new record is created but only the autoincremented field is filled, the others are empty, null.
I tried mapper->submit() and model->submitAll().Maybe it's because mapping is happening in the constructor of the form? And the controls on the form have not yet been fully created?
-
Are you sur the mapper is valid ?
Why is it not part of your dialog rather than passed around ? -
Check the current index.
-
Your record is empty - so what's your db structure. Does it allow NULL values, has it a PK?
-
The table does have a primary key.
The record gets inserted in the database, so I guess it allows NULL values. -
This post is deleted!
-
I want to use it in the child for inserting a new record. mx player for pc mxplayer
-
The logic should be the other way around.
Use the dialog to get the data from your application user. Then create the record based on the data you extract from the dialog.
This will also allow you to properly handle cancellation of the dialog. Otherwise you may end up with empty rows in the database that you will need to remove because you added it too early in your business logic.