#include <delegate.h>
Public Member Functions | |
ComboBoxDelegate (QObject *parent=0) | |
QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
void | setEditorData (QWidget *editor, const QModelIndex &index) const |
void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
void | updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const |
Definition at line 29 of file delegate.h.
ComboBoxDelegate::ComboBoxDelegate | ( | QObject * | parent = 0 ) |
Definition at line 46 of file delegate.cpp.
: QItemDelegate(parent) { }
QWidget * ComboBoxDelegate::createEditor | ( | QWidget * | parent, |
const QStyleOptionViewItem & | option, | ||
const QModelIndex & | index | ||
) | const |
Definition at line 50 of file delegate.cpp.
{ QComboBox *editor = new QComboBox(parent); editor->insertItem(0,"INT"); editor->insertItem(1, "VARCHAR"); editor->insertItem(2, "BOOL"); editor->insertItem(3, "DATE"); editor->insertItem(4, "TIME"); return editor; }
void ComboBoxDelegate::setEditorData | ( | QWidget * | editor, |
const QModelIndex & | index | ||
) | const |
Definition at line 60 of file delegate.cpp.
{ QString value = index.model()->data(index, Qt::EditRole).toString(); QComboBox *combo = static_cast<QComboBox*>(editor); combo->setEditable(true); combo->setEditText(value); }
void ComboBoxDelegate::setModelData | ( | QWidget * | editor, |
QAbstractItemModel * | model, | ||
const QModelIndex & | index | ||
) | const |
Definition at line 67 of file delegate.cpp.
{ QComboBox *combo = static_cast<QComboBox*>(editor); model->setData(index, combo->currentText()); }
void ComboBoxDelegate::updateEditorGeometry | ( | QWidget * | editor, |
const QStyleOptionViewItem & | option, | ||
const QModelIndex & | index | ||
) | const |
Definition at line 72 of file delegate.cpp.
{ editor->setGeometry(option.rect); }