// Setup the model to use in the mapper
model->setTable("Orders");
model
->setRelation
(7,
QSqlRelation("customers",
"CustomerNumber",
"Name"));
model
->setRelation
(5,
QSqlRelation("employee",
"EmployeeNumber",
"UserName"));
model->select();
Qt::SortOrder order = Qt::AscendingOrder;
model->sort(0, order);
// Setup the mapper for the order widgets
mapper->setModel(model);
mapper->addMapping(ui->idLineEdit, 0);
mapper->addMapping(ui->fullfilledCheckBox,1);
mapper->addMapping(ui->fullfilledDateEdit, 2);
mapper->addMapping(ui->orderDateEdit, 3);
mapper->addMapping(ui->dueDateEdit, 4);
mapper->addMapping(ui->employeeComboBox, 5, "currentIndex");
mapper->addMapping(ui->dueTimeEdit, 6);
mapper->addMapping(ui->customerComboBox, 7, "currentIndex");
// Setup the model to use in the mapper
model = new QSqlRelationalTableModel(this);
model->setTable("Orders");
model->setRelation(7, QSqlRelation("customers", "CustomerNumber", "Name"));
model->setRelation(5, QSqlRelation("employee", "EmployeeNumber", "UserName"));
model->select();
Qt::SortOrder order = Qt::AscendingOrder;
model->sort(0, order);
// Setup the mapper for the order widgets
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
mapper->setModel(model);
mapper->setItemDelegate(new QSqlRelationalDelegate(model));
mapper->addMapping(ui->idLineEdit, 0);
mapper->addMapping(ui->fullfilledCheckBox,1);
mapper->addMapping(ui->fullfilledDateEdit, 2);
mapper->addMapping(ui->orderDateEdit, 3);
mapper->addMapping(ui->dueDateEdit, 4);
mapper->addMapping(ui->employeeComboBox, 5, "currentIndex");
mapper->addMapping(ui->dueTimeEdit, 6);
mapper->addMapping(ui->customerComboBox, 7, "currentIndex");
To copy to clipboard, switch view to plain text mode
Bookmarks