tags:

views:

121

answers:

1

I have an table view showed

part description, quantity, price

And I have a Model/View using this code

model = new QSqlRelationalTableModel(this);
model->setTable("parts");
model->setRelation(3,QSqlRelation("part_tbl","part_id","part_desc"));

model->select();
ui->tableView->setModel(model);

I need to add a new column that shows quantity * price in the table view. It's important to know I'm using QsqlRelationalTableModel

Help is appreciated, Thanks in advance

A: 

I think your best bet for handling this is to make either a model that inherits QSqlRelationalTableModel, or one that acts as a proxy (and contains a member for the model). Your new model will add the extra column, and when the data is requested for that column, use the data from the other columns to compute what is required.

Caleb Huitt - cjhuitt
At first, I would like to send a big thanks for you.In fact I'm trying to solve this issue using long way. I have created an empty column in the database called it total, now I'm trying programmability to add the two columns into the empty column. Many thanks again for your help.