문제

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");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top