[Qt-interest] Animated QProgressBar in a QTableView
Andre Somers
andre at familiesomers.nl
Thu Sep 2 21:20:22 CEST 2010
Hi,
I think you are right about your critique, but I wanted to comment on
one issue (just for the lurkers out there ;-) )
Op 2-9-2010 19:12, Stephen Kelly schreef:
> If you want real decoupling of model from everything else (the whole
> point) never put additional accessors (like getEmitters) on your model.
>
I think the idea is that you should never put additional accessors on
your model for the views or delegates that interact with it. That should
all stay inside the QAbstractItemModel interface. But, for back-end code
that interacts with the model, I think it is perfectly fine to add
custom accessors on your model. Compare with for instance the
QFileSystemModel. It adds quite a bit of file system specific API on the
model class, but all of this API is for use by the back-end part of the
code, not for use by the views.
Remember that a QAbstractItemModel derived class is supposed to only
provide a view on an existing source of data in your application. It is
an adaptor with a standardized interface between your actual data store
and the UI views on that data. In a nicely separated design, that will
often mean that you need to define slots in your model so it can be
signalled of changes in the data store.
André
More information about the Qt-interest-old
mailing list