[PyQt] Question regarding single model and multiple views...
newellm at blur.com
Thu Oct 1 06:29:37 BST 2009
On Wednesday 30 September 2009 18:51:39 bvz wrote:
> Thanks for the quick reply.
> I was considering that (hiding columns) but that seems really really
> inefficient. There could be as many as 25 tables with 7-8 columns each
> (but not much data... rarely more than 20 rows). Hiding columns would mean
> a lot of duplicated info...
> <scratches head>
> ...unless QT is smart enough not to populate the hidden columns? That
> actually sounds like it could be the case here. Hmmm.
It's not inefficient at all. I'm pretty sure that none of the item views in
qt would be asking for any data from the model for any hidden columns or
No info would be duplicated because the views don't store any data, they
retrieve the data from the model on demand.
> Your other suggestion to write a wrapper has me a little confused. My data
> model already has the smarts to do all the filtering, it just doesn't know
> what table is requesting it. I don't understand how wrapping it in anything
> gets me any additional info.
The wrapper would simply make the existing model appear to only have the
columns that each view desires. So you would have an instance per view.
Since it would only be passing on calls for data after mapping the
QModelIndex, it wouldn't duplicate data or have much overhead.
This isn't needed though if you simple need to hide columns, as QTreeView and
QTableView both support that fine.
That's the very design of those classes, to show what columns you want, in
what order you want.
More information about the PyQt