特定の状態が設定されるたびに、以前に設定した位置から移動したいオブジェクトがあります。私はxPosと呼ばれる別のプロパティを作成しようとしましたが、バインディングループエラーを回避しようとしました。このエラーは、状態が設定された後にオブジェクトの新しい位置xによって設定され、次にその特定の状態に再び切り替えることができるように同じ状態を呼び出すことは何もしませんが、それはうまくいかないようです。ここで QML:状態を使用して前の設定された位置からオブジェクトを移動する方法
は、私のコードの抜粋です:property int xPos: 0
states: [
State {
name: "nextStep"
PropertyChanges {
target: progressBar_Id
x: -1*(progressBar_Id.step.width) + xPos
}
},
State {
name: "previousStep"
PropertyChanges {
target: progressBar_Id
x: progressBar_Id.step.width + xPos
}
},
State {
name: "default"
PropertyChanges {
target: progressBar_Id
x: xPos
}
}
]
transitions: [
Transition {
from: "*"
to: "nextStep"
NumberAnimation {properties: "x"; easing.type: Easing.Linear; duration: 1000}
onRunningChanged: {
if(!running) {
xPos = progressBar_Id.x;
console.info("xPos = " + xPos);
state = "default";
}
}
},
Transition {
from: "*"
to: "previousStep"
NumberAnimation {properties: "x"; easing.type: Easing.Linear; duration: 1000}
onRunningChanged: {
if(!running) {
xPos = progressBar_Id.x;
console.info("xPos = " + xPos);
state = "default";
}
}
}
]
XPOSは、コンソール出力から最初の時間を設定し得るように見えるが、決してオブジェクトに新しいのxCoordが適用されます。