[Qt-qml] QML models and components.
Lars Kinnunen
lars.kinnunen at nomovok.com
Fri Jul 16 22:03:55 CEST 2010
Hi, I am trying to understand how QML models and components work, while
trying to understand demo code, I ran into this problem. I am wondering
how it is supposed to work. console message is supposed to return 100,
but it returns 0, where is the glitch?
And as a bonus, how do I get First_Child to show.
BR, Lars
-----------------------------------------------------------
import Qt 4.7
Rectangle {
id: mainWindow
width: 200; height: 100;
VisualDataModel {
id: mainVisualModel;
model: ListModel {
id: mainModel
ListElement { name: "First" }
}
delegate: Component {
id: mainDelegate;
Package {
Item {
Package.name: 'overview';
Text { text: name; anchors.fill: parent; }
VisualDataModel {
id: childvisualModel;
delegate: Package {
id: childDelegate;
Item {
id: stackItem
Package.name: 'stack'
z: stackItem.PathView.z
}
Text { text: name; anchors.fill: parent; }
Component.onCompleted: {
console.log("Error Test == "+stackItem.PathView.z)
}
}
model: ListModel {
id: childModel
ListElement { name: "First_Child" }
}
}
PathView {
id: mainpathview;
anchors.fill: parent;
model: childvisualModel.parts.stack;
pathItemCount: 3
path: Path {
PathAttribute {
name: 'z';
value: 100.0
}
}
}
}
}
}
}
ListView {
anchors.fill: parent;
model: mainVisualModel.parts.overview;
interactive: true
}
}
More information about the Qt-qml
mailing list