Quote Originally Posted by wysota View Post
How do your setEditorData() and setModelData() implementations look like?
Qt Code:
  1. void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
  2. {
  3. QComboBox *edit = qobject_cast<QComboBox *>(editor);
  4. QString value = index.model()->data(index, Qt::EditRole).toString();
  5. edit->setCurrentIndex(edit->findText(value));
  6. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
  2. const QModelIndex &index) const
  3. {
  4. QComboBox *edit = qobject_cast<QComboBox *>(editor);
  5. QString oldVal = index.model()->data(index, Qt::EditRole).toString();
  6. QString newVal = edit->currentText();
  7. if (oldVal != newVal)
  8. {
  9. model->setData(index, newVal);
  10. }
  11. // qDebug() << "setModelData: index = " << edit->currentIndex();
  12. }
To copy to clipboard, switch view to plain text mode 

I know what you're going to say right here, the answer is in setModelData. sure, yes.
But I don't use QComboBox::currentIndex() here, I need to access it outside these methods to evaluate the selections/entry of both columns before calling a saveRecord() method.