[Qt-interest] Alignment in QTableView
Rob Simmermon
rob.simmermon at simmtechsolutions.com
Wed May 26 17:55:34 CEST 2010
I had to switch from a QTableView to a QTableWidget (Same for QTreeView) to
give me more control over columns and how they are laid out. That led me to
have to implement my own set of utilities for using QSqlQuery's to populate
the views.
That's really my own complaint, too, about the MVC, is that in Qt, the
presentation of the data when using QTableView and QTreeView with models is
really not isolated. It should be in the view and not the model. Just like
Mr. Harmer said below. Just getting the current properties of a displayed
view is a nightmare using QTableView and QTreeView.
Hope they can change that somehow in an upcoming release.
-----Original Message-----
From: Sean Harmer [mailto:sean.harmer at maps-technology.com]
Sent: Wednesday, May 26, 2010 10:40 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Alignment in QTableView
On Wednesday 26 May 2010 16:22:49 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?
First thing that springs to mind is a very simple proxy model that overrides
the data() function for the Qt::TextAlignmentRole for the column that you
wish
to customise.
Probably best to inherit your proxy model from QSortFilterProxyModel to save
yourself some headaches.
I agree that this type of presentational customisation should be handled by
the views rather than the models though. To me, the model data should not
include things like text colour, alignment etc.
HTH,
Sean
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list