直接上代码:- import QtQuick 1.0
- Item {
- Rectangle {
- id: buttonRect
- width: 96
- height: 96
- color:"black"
- Image {
- id: img
- source: "./tux.png"
- anchors.centerIn:parent
- }
- MouseArea {
- id:mouseArea
- anchors.fill: parent
- }
- states: State {
- name: "down"; when: mouseArea.pressed == true
- PropertyChanges { target:buttonRect ; y: y + 3 ; x : x + 3; }
- }
- }
- }
上面代码目标实现一个
按钮的功能。当点击按钮时,按钮会向右向下移动3像素,以模拟被按下的情况。目前程序运行正常,但是在按下按钮时,会打印如下警告:
QML Rectangle: Binding loop detected for property "y"
QML Rectangle: Binding loop detected for property "x"
求能消除这些警告的方法。
不考虑重定向
错误输出,禁止waring的解决方法。