BoundaryRule QML Type
定义对数值属性可设置值范围的限制。更多
Import Statement: | import Qt.labs.animation |
属性
- currentOvershoot : real
- easing : enumeration
- enabled : bool
- maximum : real
- maximumOvershoot : real
- minimum : real
- minimumOvershoot : real
- overshootFilter : enumeration
- overshootScale : real
- peakOvershoot : real
- returnDuration : int
信号
方法
- bool returnToBounds()
详细说明
边界规则(BoundaryRule)定义了特定属性的允许取值范围。当设置的值超出范围时,它会通过缓和曲线施加 "阻力"。
例如,下面的 BoundaryRule 可以防止DragHandler 将矩形拖得太远:
import QtQuick import Qt.labs.animation Rectangle { id: root width: 170; height: 120 color: "green" DragHandler { id: dragHandler yAxis.minimum: -1000 xAxis.minimum: -1000 onActiveChanged: if (!active) xbr.returnToBounds(); } BoundaryRule on x { id: xbr minimum: -50 maximum: 100 minimumOvershoot: 40 maximumOvershoot: 40 } }
请注意,一个属性不能有多个指定的 BoundaryRule。
另请参阅 Qt Quick 中的动画和过渡,行为示例、 Qt Qml和Qt Quick 示例 - 指针处理程序。
属性文档
currentOvershoot : real |
easing : enumeration |
该属性保留在超调模式下应用的缓和曲线(当违反minimum 或maximum 约束时,而值仍在各自的超调范围内)。
默认的缓和曲线为QEasingCurve::OutQuad 。
enabled : bool |
当跟踪属性的值发生变化时,是否执行该规则。
默认情况下,BoundaryRule 。
maximum : real |
该属性保留了该属性允许具有的最大无约束值。如果属性设置为较大值,则将受easing 和maximumOvershoot 约束。
默认值为1
。
maximumOvershoot : real |
minimum : real |
该属性保留了允许该属性具有的最小无约束值。如果属性设置为更小的值,它将受easing 和minimumOvershoot 约束。
默认值为0
。
minimumOvershoot : real |
overshootFilter : enumeration |
该属性指定了应用于截取属性值的聚合函数。
如果设置为BoundaryRule.None
(默认值),则截取的属性值的过冲限制为currentOvershoot 。如果设置为BoundaryRule.Peak
,则截取的属性值的过冲限制为peakOvershoot 。
overshootScale : real |
该属性保留easing 在超调条件下的缩放量。例如,如果一个项目被限制移动超过某个限制的 100 像素,而用户(通过某个输入处理程序)试图拖动它超过限制 100 像素,如果 overshootScale 设置为 1,用户就会成功:缓和曲线的唯一作用是改变项目从超调 0 到超调 100 的移动速度。但如果设置为 0.5,BoundaryRule ,则会提供阻力,当用户尝试移动 100 像素时,项目只会移动 50 像素;缓和曲线会调节移动速度,使其在开始时与用户尝试的移动同步,然后根据缓和曲线的形状放慢速度。
默认值为 0.5。
peakOvershoot : real |
在调用returnToBounds() 之前,该属性保留currentOvershoot 的最正或最负值。
当截取的属性值已知会波动时,如果想找到最大超调量而不是波动值并作出反应,这将非常有用。
另请参阅 overshootFilter 。
returnDuration : int |
该属性是returnToBounds() 将目标属性返回到最近边界所需的时间(毫秒)。如果设置为 0,returnToBounds() 将立即设置属性,而不是创建动画作业。
默认值为 100 毫秒。
信号文档
returnedToBounds() |
在违反maximum 或minimum 约束后,当currentOvershoot 再次返回0
时,会发出该信号。如果是动画返回,则在动画完成时发出该信号。
注: 相应的处理程序是onReturnedToBounds
。
另请参阅 returnDuration 和returnToBounds()。
方法文档
bool returnToBounds() |
将截获的属性返回minimum 和maximum 之间的一个值,这样currentOvershoot 和peakOvershoot 都为零。如果returnDuration 大于零,则会生成动画。
如果数值需要调整,则返回 true;如果已经在范围内,则返回 false。
另请参见 returnedToBounds 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.