OK、私のケースに問題が見つかりました。
私Qt.createQmlObject()
は次のように使用しました:
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"
}
}
}
これは機能しないため、次のように変更しました。
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, "");
}
}
}
動作しますが、期待どおりではありません! ご覧のとおりQt.createQmlObject()
、要素内で実行しても、Row
要素の重要な推定の一部が再計算されませんRow
。これをhttps://bugreports.qt-project.org/browse/QTBUG-40356
でバグとして報告しました