-1
は、私はこのようなQMLスクリプトでLayoutプロパティにアクセスしたい:QMLのレイアウトにアクセスするには?
function foobar()
{
var element = <QML "Text" in "GridLayout">;
element.Layout.topMargin = 23;
}
これは可能ですか?
は、私はこのようなQMLスクリプトでLayoutプロパティにアクセスしたい:QMLのレイアウトにアクセスするには?
function foobar()
{
var element = <QML "Text" in "GridLayout">;
element.Layout.topMargin = 23;
}
これは可能ですか?
は、次のように行うには全く問題ありません:
GridLayout {
anchors.fill: parent
Text {
id: txt
Layout.topMargin: 100
}
}
...
txt.Layout.topMargin = 10;
しかし、私は正しい方法がより宣言的な方法でそれを行うことです推測:あなたはあなたができるかどうかについて尋ねていると仮定すると、
GridLayout {
anchors.fill: parent
Text {
id: txt
property int topMargin: 100
Layout.topMargin: topMargin
}
}
...
txt.topMargin = 10;
アイテムの添付されたプロパティに外部的/動的にアクセスします。
例:
ColumnLayout {
Rectangle {
Layout.fillHeight: true
Layout.fillWidth: true
}
Rectangle {
id: bottomRect
}
}
MouseArea {
onClicked: {
bottomRect.Layout.fillHeight = true;
}
}
あなたがいない、その後、
< "< element type >" in "< parent element type >" >
構文を使用して要素にアクセスして話をしている場合。それは解釈しません。
GridLayoutに 'id'フィールドを割り当ててコード内で参照するのはなぜですか? – selbie