[Qt-interest] QTableView::addColumn()

Neel Basu neel.basu.z at gmail.com
Mon Dec 22 17:11:24 CET 2008


On Monday 22 Dec 2008 8:50:10 pm Greg Beauchesne wrote:
> Neel Basu wrote:
> > 
> > Model means it delivers concrete data. 
> > when you are making a table suppose a marksheet table marks of subjects of 
> > different students are the concrete values 
> > Total and avg are for representation and they are not going to take any place 
> > on record or storage.
> > so they should not come from model.
> 
> Data from the model doesn't necessarily have to come from storage
> either. The "Interview" demo that comes with Qt is a perfect example of
> this, demonstrating a model that does nothing but generate 1000 rows of
> data for every tree branch. No storage involved (other than caching
> model indexes). In your case, it sounds like you need to make a proxy
> model that wraps your original model and adds the columns you are
> interested in.
> 
> Barring that, you could always use QStandardItemModel and manually add
> all the columns you want, but you'd lose the benefit of model updates
> being automatically propagated to your views.
> 
> > why would there be a representation specific overhead on model ??
> > When you are isolating view for representation all representation specific 
> > things should go in View.
> > Both model and view might have calculation overhead.
> > but Model's calculation overhead should be limited to storage specific it 
> > might also deal with data to deliver something else by conditional checking.
> > But it should never **CARE** for presentation layer.cause people can plug the 
> > same model into different views where the are viewing the **SAME THING(model 
> > data)** from different aspects/angles. and its not possible for a model to 
> > forsee all this aspects/angles.
> > and view layer should always deal only with representation part and it should 
> > be able to do calculations specific to representation.
> 
> See above. Your base model can be concerned only with storage, and your
> proxy model can provide the calculated data for your base model. Other
> views that don't need your additional columns can use the base model
> instead of the proxy model.

Your Idea of Proxy Model is good. but If I do it in that way there would be an unnecessary calculation overhead
on Model which can also be done by View.
However I've noticed that <Qt3 had addColumn() functions on Views thats why I was saying that they shouldalso be present in Q4
cause different people can entertain their different tastes.



More information about the Qt-interest-old mailing list