#include "datedelegate.h"
|
|
DateDelegate::DateDelegate(QObject *parent):QItemDelegate(parent)
|
{
|
|
}
|
|
QWidget *DateDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
{
|
QDateTimeEdit *de = new QDateTimeEdit(parent);
|
de->setDate(QDate::currentDate());
|
de->setDisplayFormat("yyyy");
|
return de;
|
}
|
|
void DateDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
{
|
QString ct = ((QDateTimeEdit*)editor)->text();
|
model->setData(index,ct);
|
}
|