33 : QItemDelegate(parent)
42 const QStyleOptionViewItem & ,
43 const QModelIndex & )
const
45 QDoubleSpinBox *editor =
new QDoubleSpinBox(parent);
46 editor->setMinimum(m_min);
47 editor->setMaximum(m_max);
48 editor->setDecimals(m_decimals);
49 editor->setSingleStep(m_step);
51 connect(editor, SIGNAL(valueChanged(
double)),
this, SLOT(valueChanged()));
58 double value = index.model()->data(index, Qt::EditRole).toDouble();
60 QDoubleSpinBox *spinBox =
static_cast<QDoubleSpinBox *
>(editor);
61 spinBox->setValue(value);
65 const QModelIndex &index)
const
67 QDoubleSpinBox *spinBox =
static_cast<QDoubleSpinBox *
>(editor);
68 spinBox->interpretText();
69 double value = spinBox->value();
71 model->setData(index, value, Qt::EditRole);
75 const QModelIndex & )
const
77 editor->setGeometry(option.rect);
80 void DoubleSpinDelegate::valueChanged()
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
void setEditorData(QWidget *editor, const QModelIndex &index) const
DoubleSpinDelegate(QObject *parent=nullptr)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const