#include "combodelegate.h" ComboDelegate::ComboDelegate(QObject *parent) : QItemDelegate(parent) {} QWidget *ComboDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem, const QModelIndex) const { QComboBox *comboBox = new QComboBox(parent); comboBox->addItem("One"); comboBox->addItem("Two"); comboBox->addItem("Three"); return comboBox; } void ComboDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::EditRole).toString(); QComboBox *comboBox = static_cast(editor); comboBox->setEditText(value); } bool ComboDelegate::eventFilter(QObject, QEvent *event) // prevents ListView popup from closing immediately { if(event->type()==QEvent::FocusOut) return true; return false; }