The alternative to subclussing QItemDelegate
is to subclass your model and override data()
method.
QVariant MyModel::data(const QModelIndex& index, int role) const {
if (index.column() == yourCellIndex && role == Qt::TextAlignmentRole) {
return Qt::AlignLeft;
} else {
return QVariant();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…