[Qt-interest] Alignment in QTableView
Andre Somers
andre at familiesomers.nl
Wed May 26 18:21:52 CEST 2010
Hi,
On 26-5-2010 17:55, Rob Simmermon wrote:
> 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.
>
Problem is, that there you are basically putting your data in the view
again, which also is not a very desirable solution. For me, I think that
the proxy model approach is a reasonable middle at the moment, but it
does not always suffice of course.
> 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.
>
That would be no earlier than 5.0, I guess, which is not planned yet AFAIK.
I don't agree that the current setup is a nightmare; it really is not
that hard to query QAbstractItemView directly if you want. What is
really hard is creating a tree model based on QAbstractItemModel, but
that's just a pet-gripe of mine...
Still, it *is* quite complex, and there is no clear separation of data
and presentation. Delegates come close to providing this, but they can
be cumbersome to use I find. You could add your own data roles to your
model, and use a delegate to come up with a good presentation of that.
Not easy, not fast, and not very easy to reuse.
It would be nice if you could easily create some light-weight layout
rules, perhaps in a CSS like way. The presentation of items is of course
always based on their state. That state can be in the main model like in
the case of the checked state we have now, but perhaps it should also be
easier to attach user-defined states to an existing model without
actually changing that model. Currently, there is only one such a state
like this that lives outside the model itself, and that is the selection
as presented in the selection model. If you could attach your own such
state-carrying models to your data models and optionally share them
across views, you would end up with a very flexible system. If you
combine that with an easy to use CSS-like way to define how states
influence presentation, where states can act as CSS selectors or
pseudo-states, I think you have a real winner.
Perhaps all of the above is already possible based on the current base
or could be added to Qt in a binairy compatible way. It is worth
thinking about in any case...
André
More information about the Qt-interest-old
mailing list