[Qt-interest] How Can I align to right a specific column from QTableView ?
Stefano Rosellini
s.rosellini at iv-srl.it
Thu Oct 22 17:19:05 CEST 2009
Take a look at
http://doc.trolltech.com/4.5/model-view-creating-models.html for
explanation.
This example to align center column 3:
QVariant StringListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
/* ... */
if (role == Qt::AlignmentRole && index.column() == 3)
return Qt::AlignHCenter;
return QVariant();
}
Mhayk Whandson ha scritto:
> Hi Stefano,
>
> Is this fuction ?
>
> QVariant QSqlQueryModel::data ( const QModelIndex & item, int role =
> Qt::DisplayRole )
>
> I would like that all items from a specific columns align to center.
> Could you show me an example ?
>
> best regards,
>
> On Thu, Oct 22, 2009 at 10:48 AM, Stefano Rosellini
> <s.rosellini at iv-srl.it> wrote:
>
>> In "data" method of your model you must reply to Qt::TextAlignment
>> request of that column with the correct alignment. The other option is
>> to use a delegate for that view.
>>
>> Mhayk Whandson ha scritto:
>>
>>> hi all,
>>>
>>> I would like to align a specific column from QTableView, could you help me ?
>>>
>>>
>>> best regards,
>>>
>>>
>>>
>> --
>> Stefano Rosellini
>> Informatica Valdinievole
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
>
>
>
--
Stefano Rosellini
Informatica Valdinievole
More information about the Qt-interest-old
mailing list