Hello to everybody,
I read some post on this forum but i didn't found any answer to my problem. I hope you could help me
I've a table (Carichi) with a Foreing key of an other table (Colori), so I create my QSqlRelationalTableModel;
Qt Code:
  1. //Definizione del modello principale
  2. myModel = new QSqlRelationalTableModel(this);
  3. myModel->setTable("Carichi");
  4. myModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
To copy to clipboard, switch view to plain text mode 
Now I create the relationModel to a new QSqlTableModel:
Qt Code:
  1. int custIndexCol=myModel->fieldIndex("CodCol");
  2. myModel->setRelation(custIndexCol,QSqlRelation("Colori","idColori","Colore"));
  3.  
  4. //Definizione del modello del colore
  5. mdlCol = myModel->relationModel(custIndexCol);
  6. mdlCol->setEditStrategy(QSqlTableModel::OnManualSubmit);
  7. ui->cboColore->setModel(mdlCol);
  8. ui->cboColore->setModelColumn(mdlCol->fieldIndex("Colore"));
  9. ui->cboColore->setItemDelegate(new QSqlRelationalDelegate(ui->cboColore));
To copy to clipboard, switch view to plain text mode 

Now I've all my components (also a QComboBox to display items).

Now I'd like that the user can edit the QComboBox (setting it editable isn't it?) also adding a new element (that not is into Colori) and adding it to base table Colori, so it create the element for the foreign key and the table Carichi can save the new element created.

I thought that setting QComboBox editable could be enought, seen the model linked by setModel(), but, I understood that isn't!!

I hope I explain correctly enought my problem

Thanks a lot for your time

Michele