Delete children of QML Grid
问题 I want to loop through a QML Grid's children and destroy each of them using Javascript. Grid { id: contentGrid spacing: 10 ImageItem { imageSource: "file:/foo.jpeg" } // destroy this ImageItem { imageSource: "file:/bar.jpeg" } // destroy this as well } I tried to do something like this but it's not working so far. for(var i = 0; contentGrid.children.length() < i; i++) { contentGrid.childAt(i).destroy(); } 回答1: You have a number of problems in your attempt above... First, you'll need to