MouseEvent QML Type
提供有关鼠标事件的信息。更多
Import Statement: | import QtQuick |
属性
- accepted : bool
- button : enumeration
- buttons : int
- flags : int
- modifiers : int
- wasHeld : bool
- x : real
- y : real
详细说明
通过x 和y 属性可以找到鼠标的位置。可通过button 属性查看导致事件发生的按钮。
另请参阅 MouseArea 。
属性文档
accepted : bool |
将accepted 设置为 true 可以防止鼠标事件传播到该项目下面的项目。
一般来说,如果该项目对鼠标事件做出反应,则应接受该事件,以免堆叠顺序中较低的项目也对同一事件做出反应。
button : enumeration |
该属性包含引发事件的按钮。它可以是
buttons : int |
该属性包含事件发生时按下的鼠标按钮。对于鼠标移动事件,这是所有按下的按钮。对于鼠标按下和双击事件,包括引发事件的按钮。对于鼠标释放事件,则不包括引发事件的按钮。
该属性包含一个按位组合,即......:
flags : int |
该属性包含提供鼠标事件附加信息的标志。
- Qt.MouseEventCreatedDoubleClick - 表示 Qt 已为此事件创建了双击事件。该标志在按下按钮的事件中设置,而不在由此产生的双击事件中设置。
modifiers : int |
该属性保存事件发生前的键盘修改器标志。
它包含以下按位组合
- Qt.NoModifier - 未按下修改器键。
- Qt.ShiftModifier - 按下键盘上的 Shift 键。
- Qt.ControlModifier - 按下键盘上的 Ctrl 键。
- Qt.AltModifier - 按下键盘上的 Alt 键。
- Qt.MetaModifier - 按下键盘上的 Meta 键。
- Qt.KeypadModifier - 按下键盘按钮。
例如,对 Shift 键 + 鼠标左键点击做出反应:
MouseArea { onClicked: (mouse)=> { if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier)) doSomething(); } }
wasHeld : bool |
如果鼠标左键按下时间超过阈值(800 毫秒),则该属性为真。
© 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.