[Qt-interest] Alignment in QTableView
Andre Somers
andre at familiesomers.nl
Wed May 26 17:33:24 CEST 2010
On 26-5-2010 17:22, Yves Bailly wrote:
> Hello list,
>
> Here's a (probably) basic question, but I really can't find a
> solution. Using a QTableView to display the contents of an
> SQL database (using a QSqlTableModel), I would just want to
> have a right-aligned column... but I just can't find a non-insane
> way of doing this SIMPLE thing...
>
> Any hint?
>
Normally, alignment is controlled by one of the roles for the data
method of the model. You have three options:
1) subclass QSqlTableModel and reimplement data to return the correct
value for the alignment role and the column you want.
2) create a proxy model implementation that basically does the same
(which is a bit more flexible, as you could apply it to other existing
models such as the file system model).
3) create a delegate that overrides the alignment set by the model.
In my view, all of the above are valid approaches.
André
More information about the Qt-interest-old
mailing list