I think this works (I don't try it):
You need to subclassing "QStyledItemDelegate" (or "QItemDelegate") and reimplementing its "paint" function, example:
//MyItemDelegate is subclass of QStyledItemDelegate
{
opt.decorationAlignment = Qt::AlignCenter;
QStyledItemDelegate::paint(painter, opt, index );
}
//your app body
table->setItemDelegate(new MyItemDelegate);
//MyItemDelegate is subclass of QStyledItemDelegate
void MyItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
QStyleOptionViewItem opt = option;
opt.decorationAlignment = Qt::AlignCenter;
QStyledItemDelegate::paint(painter, opt, index );
}
//your app body
table->setItemDelegate(new MyItemDelegate);
To copy to clipboard, switch view to plain text mode
Bookmarks