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.

Qt Code:
  1. import QtQuick 1.0
  2. Rectangle {
  3. width: 100
  4. height: 100
  5. VisualItemModel {
  6. id: itemModel
  7. Rectangle { height: 30; width: 80; color: "red" }
  8. Rectangle { height: 30; width: 80; color: "green" }
  9. Rectangle { height: 30; width: 80; color: "blue" }
  10. }
  11.  
  12. ListView {
  13. anchors.fill: parent
  14. model: itemModel
  15. focus: true
  16. Keys.onPressed: {
  17. console.log("Number of children: " + model.children.count);
  18. }
  19. }
  20. }
To copy to clipboard, switch view to plain text mode