+ // set the correct item selected for the editor:
+ // get the item id from the parent view's model
+ int id = index.model()->data(index, Qt::DisplayRole).toInt();
+ QComboBox *cbox = qobject_cast<QComboBox *>(editor);
+ // create a start index from combobox model
+ QModelIndex startInd = model->index(0, modelIdColumn);
+ // search an index for selected item in parent view
+ QModelIndexList indList = model->match(startInd, Qt::DisplayRole, id);
+ // if no match set no item selected
+ int ind = indList.empty() ? -1 : indList.first().row();
+ cbox->setCurrentIndex(ind);