#include <QtGui>
#include "delegate.h"
#include <delegate.h>
#include <comboboxdelegate.h>
ComboBoxDelegate
::ComboBoxDelegate(QObject *parent
){
}
{
editor->addItem("a");
editor->addItem("b56");
editor->addItem("cc");
return editor;
}
void ComboBoxDelegate
::setEditorData(QWidget *editor,
{
// QString str = index.model()->data(index, Qt::EditRole);
// QComboBox *comboBox = static_cast<QComboBox*>(editor);
// comboBox->setValue(value);
// comboBox->setCurrentIndex(value);
}
{
QComboBox *comboBox
= static_cast<QComboBox
*>
(editor
);
//comboBox->interpretText();//is this important for the QComboBox delegate??
QString str
= comboBox
->currentText
();
model->setData(index, str, Qt::EditRole);
}
void ComboBoxDelegate
::updateEditorGeometry(QWidget *editor,
{
editor->setGeometry(option.rect);
}
#include <QtGui>
#include "delegate.h"
#include <delegate.h>
#include <comboboxdelegate.h>
ComboBoxDelegate::ComboBoxDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *ComboBoxDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QComboBox *editor = new QComboBox(parent);
editor->addItem("a");
editor->addItem("b56");
editor->addItem("cc");
return editor;
}
void ComboBoxDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
// QString str = index.model()->data(index, Qt::EditRole);
// QComboBox *comboBox = static_cast<QComboBox*>(editor);
// comboBox->setValue(value);
// comboBox->setCurrentIndex(value);
}
void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
//comboBox->interpretText();//is this important for the QComboBox delegate??
QString str = comboBox->currentText();
model->setData(index, str, Qt::EditRole);
}
void ComboBoxDelegate::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