View Full Version : Model/View ...Discrimination

10th August 2007, 17:58
My goal is to have several views connected to a single model. But, the catch is that I want to be able to dictate when a particular view is affected by changes in the model.

For example, lets say I'm using a QTreeView for a file directory hierarchy and a QTableView for the contents of the file itself. Using a single QAbstractItemModel, which is only populated on demand, how would I achieve this?

I tried: viewObject->disconnect(modelObject), which did not work as I expected.

Any suggestions appreciated,

10th August 2007, 18:14
See if overriding void QAbstractItemView::dataChanged helps you.
You should set a flag in your view that tells you if updates are allowed or not.
If tey are not then do nothing in your reimplementation of dataChanged.
Otherwise call the base class version.


12th August 2007, 15:17
Thank you for your response, Marcel.

I also realized that any initial populating (through the model's constructor) defeats this need, so I'll simply populate all branches of the model lazily to control the views better. -travlr