{
bool Checked = index.model()->data(index, Qt::EditRole).toBool();
CheckBox.setChecked(Checked);
CheckBox.render(painter);
}
{
return CheckBox.sizeHint();
}
{
return editor;
}
void cCheckboxDelegate
::setEditorData(QWidget *editor,
{
bool checked = index.model()->data(index, Qt::EditRole).toBool();
QCheckBox *checkBox
= static_cast<QCheckBox
*>
(editor
);
checkBox->setChecked(checked);
}
{
QCheckBox *checkBox
= static_cast<QCheckBox
*>
(editor
);
bool checked = checkBox->isChecked();
model->setData(index, checked, Qt::EditRole);
}
void cCheckboxDelegate
::updateEditorGeometry(QWidget *editor,
{
editor->setGeometry(option.rect);
}
void cCheckboxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
bool Checked = index.model()->data(index, Qt::EditRole).toBool();
QCheckBox CheckBox;
CheckBox.setChecked(Checked);
CheckBox.render(painter);
}
QSize cCheckboxDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QCheckBox CheckBox;
return CheckBox.sizeHint();
}
QWidget *cCheckboxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QCheckBox *editor = new QCheckBox(parent);
return editor;
}
void cCheckboxDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
bool checked = index.model()->data(index, Qt::EditRole).toBool();
QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
checkBox->setChecked(checked);
}
void cCheckboxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QCheckBox *checkBox = static_cast<QCheckBox*>(editor);
bool checked = checkBox->isChecked();
model->setData(index, checked, Qt::EditRole);
}
void cCheckboxDelegate::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