void DurationDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_ASSERT(index.isValid()); QStyleOptionViewItemV4 v4option = option; initStyleOption(&v4option, index); const QWidget *widget; const QStyleOptionViewItemV4 *v4 = qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option); v4 ? widget = v4->widget : widget = 0; QStyle *style = widget ? widget->style() : QApplication::style(); if (index.model()->data(index, Qt::DisplayRole).type() == QVariant::Time) { QTime length = index.model()->data(index, Qt::DisplayRole).toTime(); QString format; length >= QTime(1, 0) ? format = QString("H:mm:ss") : format = QString("m:ss"); v4option.text = length.toString(format); } style->drawControl(QStyle::CE_ItemViewItem, &v4option, painter, widget);}