помогите засунуть делегата в ячейки плз!чё я не правильно делаю?
MyDelegate::MyDelegate(
QSqlQueryModel model,
QObject *parent)
: QItemDelegate(parent),
mod(model)
{ }
QWidget *MyDelegate::createEditor(
QWidget *parent,
const QStyleOptionViewItem& /* option */,
const QModelIndex& /* index */) const {
QComboBox *editor = new QComboBox(parent);
editor->setModel(mod);
editor->installEventFilter(const_cast<MyDelegate*>(this));
return editor;
}
void MyDelegate::setEditorData(
QWidget *editor,
const QModelIndex &index) const {
QString value = index.model()->data(
index, Qt::EditRole).toInt();
QComboBox *ds = static_cast<QComboBox*>(editor);
ds->setCurrentText(value);
}
void MyDelegate::setModelData(
QWidget *editor,
QAbstractItemModel *model,
const QModelIndex& index) const {
QComboBox *ds = static_cast<QComboBox*>(editor);
ds->interpretText();
QString value = ds->currentText();
stroka = ds->currentText();
model->setData(index, value);
}
void MyDelegate::updateEditorGeometry(
QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex& /* index */) const {
editor->setGeometry(option.rect);
}