[Qt-interest] QTableView::addColumn()

Greg Beauchesne greg_b at vision-play.com
Mon Dec 22 16:20:10 CET 2008


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.



More information about the Qt-interest-old mailing list