[ fromfile: modelview.xml id: mvc ]
Controller code manages the interactions among events, models, and views.
Factory methods, delegates, and creation and destruction code in general, all fall into the realm of the Controller.
In the Qt framework, much of the Controller mechanism can be found in delegates.
Delegates control the rendering and editing of individual items in views.
Views supply default delegates that are sufficient for most purposes, although we can, if necessary, refine the ways that the default delegates render items by deriving a custom model from QAbstractItemModel.
enables views and controllers to be added or removed without requiring changes in the model.
enables multiple views to be kept up to date and consistent with the model, even if the data is being interactively edited from more than one view.
maximizes code reuse by enabling subtitution of one model for another, or one view for another.
The primary purpose of a controller class is to encapsulate controller code.
A complex application might have multiple controllers for different subcomponents, or layers, of the application.
In Qt, the base class for a wide variety of controller classes is QAbstractItemDelegate.
Code that connect
s signals to slots can also be considered controller code.
As you will see, keeping controller code out of model and view classes can yield additional design benefits.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |