좋아, 내 경우에 문제가 있음을 발견했습니다. 하지만 예상대로
import QtQuick 2.2;
Rectangle {
id: root
width: 300; height: 300
Row {
id: itemContainer
Rectangle {
width: 100; height: 50
color: "Yellow"
}
Component.onCompleted: {
var newObject = Qt.createQmlObject('import QtQuick 2.2; Rectangle {color: "red"; width: 200; height: 200}', itemContainer, "");
}
}
}
을하고 그것을 작동 :
import QtQuick 2.2;
Rectangle {
id: root
width: 300; height: 300
Row {
id: itemContainer
Component.onCompleted: {
var newObject = Qt.createQmlObject('import QtQuick 2.2; Rectangle {color: "red"; width: 200; height: 200}', itemContainer, "");
}
Rectangle {
width: 100; height: 50
color: "Yellow"
}
}
}
이없는 일을하고 난 다음과 같이 변경 :
나는 다음과 같이 Qt.createQmlObject()
을 사용! 보시다시피, 요소 안에 Qt.createQmlObject()
을 실행하면 요소의 필수 추정 중 일부를 다시 계산하지 않습니다.
버그로보고했습니다. https://bugreports.qt-project.org/browse/QTBUG-40356
나도 마찬가지입니다. Qt 5.3.0을 사용하는데 예상대로 작동하지 않습니다. '.qml' 파일에 정의 할 수 있으면 컴포넌트를 생성 할 수 있습니다. 더 자세한 정보는 문서의'Qt.createComponent()'를 보라. –