[Qt-interest] How to show the word in the center of a Tableview's cell?

Kermit Mei kermit.mei at gmail.com
Sat Apr 4 11:06:55 CEST 2009


On Fri, 2009-04-03 at 19:40 -0700, Malyushytsky, Alex wrote:
> The easiest way probably will be:
> 
> Subclass  QAbstractTableModel
> Override data():
> 
> ..........
> if (role == Qt::TextAlignmentRole )
> {
>         return Qt::AlignHCenter;
> }
> else
>  QAbstractTableModel:: data( role )
> ..............
> 
> Have not tested it, but should work.
> 
> Hope this helps,
>    Alex
?
Yes, sir, it works.

But I can't understand, data should return a object of QVariant, Why
here return At::AlignHCenter, and it works?

Thank you!




More information about the Qt-interest-old mailing list