No createObject method in Component inside javascript
-
29-10-2019 - |
문제
I have inlined Component like
Component {
id: movie_delegate
MovieListItem {
movie: movie
}
}
Now I'm trying to create new object like
movie_delegate.createObject
But there is no such method. But if I do like this:
var comp = Qt.createComponent("MovieListItem.qml");
var o = comp.createObject(model);
Everything works fine.
해결책 2
This issue has gone when I've fixed other error, which is a little bit weird since they were unrelated, but may be I just don't see relation. Anyway question is closed.
다른 팁
Do not inline the component, but use Qt.createQmlObject with a string.
e.g. (from http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html#creating-an-object-from-a-string-of-qml)
var newObject = Qt.createQmlObject('import QtQuick 1.0; MovieListItem {movie: movie}', parentItem, "dynamicSnippet1");
제휴하지 않습니다 StackOverflow