PDA

View Full Version : QHeaderView alignment



giantdragon
20th June 2011, 20:57
How to set different text alignment for each header's column, e.g. left for first column, right for second etc?

Santosh Reddy
20th June 2011, 21:47
...e.g. left for first column, right for second etc?
You need to set flags in appropriate data role (Qt::TextAlignmentRole), also note if you have custom model then you need to support this feature.

view->model()->setHeaderData(0, Qt::Horizontal, Qt::AlignLeft , Qt::TextAlignmentRole);
view->model()->setHeaderData(1, Qt::Horizontal, Qt::AlignRight, Qt::TextAlignmentRole);

giantdragon
20th June 2011, 22:29
Thanks, now all works!