Better yet, don't reimplement the delegate -- reimplement the model and it's data() method to return some other format of date for the view to use.
BTW. Just to show the delegate is not so hard to reimplement (needs some tweaking probably):
void MyItemDelegate
::drawDisplay ( QPainter * painter,
if(dat.isValid()){
dat.toString("dd.MM.yyyy"));
} else {
}
}
void MyItemDelegate::drawDisplay ( QPainter * painter,
const QStyleOptionViewItem & option,
const QRect & rect, const QString & text ) const{
QDate dat = QDate::fromString(text);
if(dat.isValid()){
QItemDelegate::drawDisplay(painter, option, rect,
dat.toString("dd.MM.yyyy"));
} else {
QItemDelegate::drawDisplay(painter, option, rect, text);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks