Hi All,
Say I have a C++ QAbstractListModel used to manipulate of collection of Item
objects. Each item has -per say- a price and year property. What I'm trying to
do is to display this model in multiple views: items with year=1980 fall in
view1, items with year=1985 fall int view2, ... As an exmple, you can look the
GraphView at:
http://research.microsoft.com/en-us/um/people/bibuxton/buxtoncollection/pivot.htm
I think the right approach for that is using a VisualDataModel and a Package
Element. The Package Element contains as much delegates as available years, and
I should create as much views as available years.
A straightforward approach might be something as follows (say my items fall
either in 1980 or 1985 category):
Delegate.qml:
Package {
Item {
Package.name: 'year1980'
}
Item {
Package.name: 'year1985'
}
// Main rectangle:
Rectangle {
id: rectangle
states: [
State {
name: '1980'
ParentChange {
target: rectangle;
parent: 1980Delegate
}
},
State {
name: '1985'
ParentChange {
target: rectangle
parent: 1985Delegate
View.qml:
Rectangle {
// Main canvas:
id: main
// Center in parent:
anchors.fill: parent
// VisualDataModel:
VisualDataModel {
id: visualModel
delegate: Delegate {id: mainPackage}
model: itemsModel
}
// View1 for 1980 items:
Grid {
id: centralView
columns: 3
// Repeater view:
Repeater
{
model: visualModel.parts.year1980
}
}
// View for 1985 items:
Grid {
id: northWestView
// To the north-west:
anchors.left: main.right
// Set number of columns:
columns: 3
// Repeater view:
Repeater
{
model: visualModel.parts.year1985
}
}
Obviously, this approach is not acceptable as I have no idea of which years
will be available inside my collection of Item objects...
Questions:
- Is this the right approach for implementing such a feature?
If yes:
- How would you "dynamically" create as much parts inside the Package Element
as available years?
- How would you "generically" access these parts? The only way today is to
refer to the part name as a string: visualModel.parts.year1980 for example...
- How would you "dynamically" create as much views as available years?
- How would you "generically" set the model on a specific view? rather than:
model: visualModel.parts.year1980
something like (in a loop): model: visualModel.parts[i]
Thanks,
Franck_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml