[Qt-interest] How to show the word in the center of a Tableview's cell?
Ferenc Stelcz
ferenc at stelcz.hu
Sat Apr 4 11:22:36 CEST 2009
Kermit Mei wrote:
> 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!
>
It returns data indeed :)
Returns data _for the role_ Qt::TextAlignmentRole, which is
Qt::AlignHCenter.
for Qt::DisplayRole it would return the data you're showing in that
particular cell.
More information about the Qt-interest-old
mailing list