{
//QSpinBox *editor = new QSpinBox(parent);
//editor->setMinimum(0);
//editor->setMaximum(100);
//editor->setGeometry(QRect(40, 30, 401, 31));
editor->setLayoutDirection(Qt::LeftToRight);
editor
->setFrameShape
(QFrame::WinPanel);
editor->setLineWidth(0);
editor->setReadOnly(true);
editor->setText("This is text test!!1");
return editor;
}
//! [1]
//! [2]
void SpinBoxDelegate
::setEditorData(QWidget *editor,
{
/* int value = index.model()->data(index, Qt::EditRole).toInt();
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue(value);*/
QTextEdit *textEdit
= static_cast<QTextEdit
*>
(editor
);
textEdit->setText("This is text test!!1");
}
//! [2]
//! [3]
{
/*QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->interpretText();
int value = spinBox->value();
model->setData(index, value, Qt::EditRole);*/
QTextEdit *textEdit
= static_cast<QTextEdit
*>
(editor
);
}
//! [3]
//! [4]
void SpinBoxDelegate
::updateEditorGeometry(QWidget *editor,
{
editor->setGeometry(option.rect);
}
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
//QSpinBox *editor = new QSpinBox(parent);
//editor->setMinimum(0);
//editor->setMaximum(100);
QTextEdit *editor = new QTextEdit(parent);
//editor->setGeometry(QRect(40, 30, 401, 31));
editor->setLayoutDirection(Qt::LeftToRight);
editor->setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
editor->setFrameShape(QFrame::WinPanel);
editor->setLineWidth(0);
editor->setReadOnly(true);
editor->setText("This is text test!!1");
return editor;
}
//! [1]
//! [2]
void SpinBoxDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
/* int value = index.model()->data(index, Qt::EditRole).toInt();
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue(value);*/
QTextEdit *textEdit = static_cast<QTextEdit*>(editor);
textEdit->setText("This is text test!!1");
}
//! [2]
//! [3]
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
/*QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->interpretText();
int value = spinBox->value();
model->setData(index, value, Qt::EditRole);*/
QTextEdit *textEdit = static_cast<QTextEdit*>(editor);
}
//! [3]
//! [4]
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
editor->setGeometry(option.rect);
}
To copy to clipboard, switch view to plain text mode
Bookmarks