8 : QStyledItemDelegate(parent)
14 const QModelIndex &index)
const
17 QComboBox *editor =
new QComboBox(parent);
21 editor->addItem(name);
26 return QStyledItemDelegate::createEditor(parent, option, index);
33 QComboBox *cb = qobject_cast<QComboBox*>(editor);
36 QString roiTypeName = index.data().toString();
38 int cbindex = cb->findText(roiTypeName);
41 cb->setCurrentIndex(cbindex);
44 connect(cb, (
void (QComboBox::*)(
int)) &QComboBox::currentIndexChanged,
48 QStyledItemDelegate::setEditorData(editor, index);
53 const QModelIndex &index)
const
56 QComboBox *cb = qobject_cast<QComboBox*>(editor);
59 QString roiType = cb->currentText();
61 model->setData(index, roiType, Qt::EditRole);
64 QStyledItemDelegate::setModelData(editor, model, index);
70 QComboBox *cb = qobject_cast<QComboBox*>(sender());
QxrdROITypeDelegate(QWidget *parent=0)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE
static int roiTypeCount()
void typeChanged(int newType)