Hi to all,
I'm looking for a solution on alignment in a QTreeView. The default alignment is AlignLeft but I need to change it for a column. Does anybody know how to do?
Thanks.
Hi to all,
I'm looking for a solution on alignment in a QTreeView. The default alignment is AlignLeft but I need to change it for a column. Does anybody know how to do?
Thanks.
For the whole view you would simply override QAbstractItemView::viewOptions() but for a certain column you might have to implement a custom delegate, override QAbstractItemDelegate::paint() and adjust QStyleOptionViewItem::displayAlignment when the index points to appropriate column.
J-P Nurmi
Or you can do it on the model level - simply set appropriate values for Qt::TextAlignmentRole.
Last edited by wysota; 15th June 2008 at 16:36.
Thanks jpn and wysota your hints are very precious!
Bookmarks