Nek*_*nto 37
到subclussing替代QItemDelegate
是继承你的模型和覆盖data()
方法.
QVariant MyModel::data(const QModelIndex& index, int role) const {
if (index.column() == yourCellIndex && role == Qt::TextAlignmentRole) {
return Qt::AlignLeft;
} else {
return QAbstractTableModel::data(index, role);
}
}
Run Code Online (Sandbox Code Playgroud)