Data mapping to a QComboBox
I am working on an invoice edit dialog. There is an invoice model that has only one row, the current order. One of the fields is payment type. On the UI, a QComboBox is used to allow the user to select the payment type. There is a table that simply contains the different payment types, having a PK and a name. The problem is that the name is being inserted into the invoice table, not the PK. Here is the code that I have:
The Payment table:
@CREATE TABLE Payment_Type (
Payment_Type_Id INTEGER PRIMARY KEY AUTOINCREMENT,
Payment_Type_Name VARCHAR(64) NOT NULL
_paymentTypeModel = new PaymentTypeModel(this, _db);
/* snip a lot of code */
I am thinking that I need to use the other version of addMapping and tell it to use the Payment_Type_Id. Or do I need to do something else?
(P.S. I am using SQLite which is why the the string is being saved into an INTEGER field)
QDataWidgetMapper is wat you need!
Well, I am using a QDataWidgetMapper, the _invoiceMapper is exactly that... I am wiring it up with this line of code:
Were are you suggesting I use the QDataWidgetMapper?
I think this post can be useful