[Qt5-feedback] Qt5's MVC
Charley Bay
charleyb123 at gmail.com
Thu May 12 16:51:19 CEST 2011
I wanted to ensure some forum thoughts on the Qt model-view-controller were
not lost:
>From Danny (in the forums):
> Throw away MVC classes and start again. The existing classes are
> cumbersome, over-complicated and assume all data can be distilled into
> lists, tables or trees which just isn’t true (e.g. graphics apps). We have
> to use our own models and the slow widget-convenience classes with heavy
> custom widgets for our applications.
>
I'm not ready to go that far -- I like the MVC, think it is quite well
designed, but yes, it is "complicated" to use. (In part, out of necessity,
it is a complicated problem.)
HOWEVER, it is possible to fix many of these things with a VERY SIMPLE
QModelWrapper class from which the user could derive (overriding a very
simple set of virtual model-API functions), IF ONLY the QModelIndex would
have value semantics for a user data type, or data type handle. For
example, I need ONE of: (a) QModelIndex contains BOTH a
user-pointer-cast-to-void, PLUS an "enum" so I can "know" which of my object
types is actually defined by that pointer; *OR* (b) QModelIndex
wholly-contains a MyHandleToMyObject type (through pointer that it deletes,
or value) so I can easily pass around handles to my heterogeneous types in
my model, with the handles getting cleaned-up through value semantics as the
QModelIndex instances come-and-go.
PROBLEM SUMMARY: Users absolutely MUST be able to use their OWN models,
which are EXPOSED to the Qt MVC infrastructure. User models are often NOT
lists, tables, and trees, and user models OFTEN must have HETEROGENEOUS
types which do not share a common "base class" (so today's "void*" payload
in the QModelIndex is insufficient -- we don't know what user-defined object
type is behind that void*).
There was a brief mention of this topic with QML model handling:
http://lists.qt.nokia.com/pipermail/qt-qml/2010-October/001422.html
...which references an older thread on the Qt MVC design itself:
http://lists.trolltech.com/qt-interest/2006-11/thread00266-0.html
As a long-term Qt user who has "drunk the QML kool-aid" (QML is so very
cool), IMHO this problem is DRAMATICALLY MORE SERIOUS in the QML world
(where atomic instances are not "constrained" to the parent/peer contexts
established through the model.)
--charley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110512/70824504/attachment-0001.html
More information about the Qt5-feedback
mailing list