When trying out the following test case, it prints 'Number of children: undefined' for VisualItemModel.children.count, is this the expected behaviour? I would have thought that the expected result would have been 3?
Checking the code in src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp:181, it looks the returned children object has the count method implemented.
import QtQuick 1.0
Rectangle {
width: 100
height: 100
VisualItemModel {
id: itemModel
Rectangle { height: 30; width: 80; color: "red" }
Rectangle { height: 30; width: 80; color: "green" }
Rectangle { height: 30; width: 80; color: "blue" }
}
ListView {
anchors.fill: parent
model: itemModel
focus: true
Keys.onPressed: {
console.log("Number of children: " + model.children.count);
}
}
}
import QtQuick 1.0
Rectangle {
width: 100
height: 100
VisualItemModel {
id: itemModel
Rectangle { height: 30; width: 80; color: "red" }
Rectangle { height: 30; width: 80; color: "green" }
Rectangle { height: 30; width: 80; color: "blue" }
}
ListView {
anchors.fill: parent
model: itemModel
focus: true
Keys.onPressed: {
console.log("Number of children: " + model.children.count);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks