Для отображения даты можно использовать свой делегат:
class SqlDelegate : public QItemDelegate
{
public:
SqlDelegate(QObject* parent = 0);
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
};
void SqlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
if (index.data().type() == QVariant::Date || index.data().type() == QVariant::DateTime)
{
QStyleOptionViewItem opt = option;
QDate dt = index.data().toDate();
QString s = dt.toString("dd.MM.yyyy");
QVariant value = index.data(Qt::TextColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid())
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
opt.displayAlignment = Qt::AlignVCenter | Qt::AlignHCenter;
drawDisplay(painter, opt, opt.rect, s);
drawFocus(painter, opt, opt.rect);
return;
}
QItemDelegate::paint(painter, option, index);
}