The user interface is used to display the interface in different scenes, or to change their appearance to the corresponding user's interaction. Typically, some column changes are concurrent. See the QML states keyword in QT help. The state attribute states.
1 Create Status
To create a status, you can add a state object to the project's States property, and the States property contains a list of the state of the project.
rectangle{ Id:window width:240; height:150 color: "Red" mousearea{ anchors.fill:parent OnClicked:window.state = "Moved" } states:[ state{ Name: "Moved" propertychanges { Target:window x:50;y:50;}} ] }
In the example above, rectangle defaults to the (0 0) position, appends a moved state, and uses the Propertychanges object to change the position of the rectangle in order to (50 50). You can change the status by clicking it. The state project defines all the changes that are to be made in the new status, you can specify additional properties for the change, or you can create additional propertychanges for other zodiac, or modify the properties of other objects, not just the object that owns the state.
2 Default state
You can use states projects to process zodiac changes in batches. In addition, you can revert directly to the project default state. Use when to go back to the original state.
rectangle{ Id:window width:240; height:150 color: "Red" mousearea{ Id:moousearea Anchors.fill:parent } states:[ state{ Name: "Moved"; when:moouseArea.pressed propertychanges { target:window x:50;y:50; }} } }}
Originally used onclicked () signal processor, call State switch. This is now implemented using the When property, which returns to the default state. You can also set property values directly.
rectangle{ Id:window width:240; height:150 color: "Red" mousearea{ Id:moousearea Anchors.fill:parent onPressed:window.state = "moved"; OnReleased:window.state = ""; } states:[ state{ Name: "Moved"; propertychanges { Target:window x:50;y:50; }} }}
Using the When property is simpler than using the signal processor to allocate state, more declarative language, and the method of the When property is recommended.
QML (10) QML status