Hi again !
It seems that by looking still a bit more I found a suitable answer.
The key was to set the QSqlRelationalDelegate for the mapper and not the QComboBox but still setting the model of the QComboBox to the table containing all the functions.
Here is my final code:
//Init all private members
//Init all private members
price1 = new QDoubleSpinBox(this);
price2 = new QDoubleSpinBox(this);
price3 = new QDoubleSpinBox(this);
price4 = new QDoubleSpinBox(this);
function = new QComboBox(this);
mapper = new QDataWidgetMapper(this);
sqlModel = new QSqlRelationalTableModel(this);
QSqlTableModel *fctModel = new QSqlTableModel(this);
QListView *articlesView = new QListView(this);
//Imediately links the views and the models
sqlModel->setTable("Articles");
//A few indexes
int nameIndex = sqlModel->record().indexOf("Name");
int priceIndex = sqlModel->record().indexOf("sellPrice");
int jobShareIndex = sqlModel->record().indexOf("jShare");
int bPriceIndex = sqlModel->record().indexOf("bPrice");
int redPriceIndex = sqlModel->record().indexOf("reducedPrice");
int functionIndex = sqlModel->record().indexOf("function");
int functionNameIndex;
{
auto tmp = new QSqlTableModel();
tmp->setTable("Functions");
functionNameIndex = tmp->record().indexOf("name");
delete tmp;
}
//Configures the sql model
sqlModel->setRelation(functionIndex, QSqlRelation("Functions", "Id", "name"));
sqlModel->setEditStrategy(QSqlTableModel::OnFieldChange);
sqlModel->select();
//Views
articlesView->setModel(sqlModel);
articlesView->setModelColumn(nameIndex); //Sets the column to the name
articlesView->setEditTriggers(QAbstractItemView::NoEditTriggers);
function->setModel(sqlModel->relationModel(functionIndex));
function->setModelColumn(functionNameIndex );
//Mapper
mapper->setModel(sqlModel);
mapper->addMapping(price1, priceIndex);
mapper->addMapping(price2, bPriceIndex);
mapper->addMapping(price3, jobShareIndex);
mapper->addMapping(price4, redPriceIndex);
mapper->addMapping(function, functionIndex);
mapper->setItemDelegate(new QSqlRelationalDelegate(mapper));
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
I hope that it will be able to help anybody who might encounter that same problem !
Happy new year everybody, take care ! :)