I 'm subclassing the QSqlRelationalDelegate and I have this (working) python code which I 'm trying to convert to Qt c++:
Qt Code:
  1. def createEditor(self, parent, option, index):
  2. # column of combo box 'position'
  3. positionColumn = 2
  4. print("myDelegate.createEditor index.column()=" + str(index.column()) + " option=" + str(option) )
  5. if index.column() == positionColumn:
  6. editor = QSqlRelationalDelegate.createEditor(self, parent, option, index)
  7. if isinstance(editor, QComboBox):
  8. editor.model().select()
  9. return editor
  10. else:
  11. return super(myDelegate, self).createEditor(parent, option, index)
To copy to clipboard, switch view to plain text mode 


What I 've done so far (don't take it as correct, it's just an effort, it's not working):
Qt Code:
  1. QWidget *BookDelegate::createEditor(QWidget *parent,
  2. const QStyleOptionViewItem &option,
  3. const QModelIndex &index) const
  4. {
  5. int positionColumn = 2;
  6. qDebug()<< "BookDelegate.createEditor index.column()=" << (index.column()) << " option=" << option ;
  7. if (index.column() == positionColumn){
  8. QWidget *editor = QSqlRelationalDelegate::createEditor(parent, option, index);
  9. //QComboBox *editor = new QComboBox(parent);
  10. //QSqlRelationalTableModel *model = qobject_cast <QSqlRelationalTableModel*>(index.model());
  11. ///QComboBox* myCombo = qobject_cast <QComboBox*>(editor);
  12. editor->model()->select();
  13. return editor;
  14.  
  15. }
To copy to clipboard, switch view to plain text mode 

Any help is welcome.