Transcript of talk: "Model/View with Qt 4"
KDE Contributor and Developer Conference
Notes taken by: Jonathan Riddell (these are not official material)
More information on the talk can be found hereModel View Controller has 3 objects to handle your data, Model has the data, View shows it on screen and Controller which works with user changes. View->takes user input->Controller->changes model->Model->sends data to be viewed.
"We quickly discovered that this split didn't work well in practical terms" says Sun on their Java Swing toolkit.
Trolltech found the same problems with MVC so Qt 4 has Model, View, Delegate and Selections. Model provides data and signals View to update itself. Model and View update other two components. View Handles user input, does item layout, calls delegate for drawing and editing the items, calls selections to do selection of items, implements view specific behavior. Delegate paints each item, performs internal layout of each item, gives the size hint and provides an editor. Model manages the data, gives notice to the view of changes in the data.
Flat views show as lists and tables. Hierarchical model presents a hierarchy of tables. Slide shows a fairly simple tree where each node represents a table. The model index with a row and column refers to a cell in the model. For a hierarchy the index has other information to indicate where it belongs.
Each item in a table can have several data elements e.g. a pixmap and a text label. Predefined roles include display (text) decoration (image) edit (shown when in edit mode) tool tip and status tip.
Selections manage selections of items and the current item. Selections are a collection of indexes. Gives notice to the view to update itself when the selection changes.
The architecture slide shows classes and their inheritance.
Various code examples, read the slides.