Obsolete Members for MouseEvent
QML 类型MouseEvent的以下成员已弃用。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。
属性
- source : int
(deprecated in 6.2)
物业文件
source : int [read-only, deprecated in 6.2]
自 QtQuick 6.2 起,此属性已被废弃。我们强烈建议不要在新代码中使用它。
请使用将 `acceptedDevices ` 设置为 `true` 的输入处理程序。
该属性保存鼠标事件的来源。
鼠标事件源可用于区分真实的鼠标事件和合成鼠标事件。当使用触摸屏和图形输入板等其他指针设备时,如果应用程序未利用实际的触摸或输入板事件,则鼠标事件可能由操作系统或 Qt 自身合成。
该值可以是以下之一:
- Qt.MouseEventNotSynthesized - 最常见的值。在提供此类信息的平台上,该值表示该事件是来自系统的真实鼠标事件。
- Qt.MouseEventSynthesizedBySystem - 表示该鼠标事件是由平台从触摸或图形输入板事件合成而成的。
- Qt.MouseEventSynthesizedByQt - 表示该鼠标事件是由 Qt 从未处理的触摸或绘图板事件合成而成的。
- Qt.MouseEventSynthesizedByApplication - 表示该鼠标事件由应用程序合成。这有助于区分应用程序生成的鼠标事件与来自系统或由 Qt 合成的鼠标事件。
例如,若要仅响应来自实际鼠标的事件:
MouseArea {
onPressed: (mouse)=> {
if (mouse.source !== Qt.MouseEventNotSynthesized)
mouse.accepted = false
}
onClicked: doSomething()
}如果按下事件的处理程序拒绝该事件,该事件将向下传播,然后下层的另一个 Item 即可处理来自触摸屏的合成事件。 例如,如果下方使用了 Flickable(且MouseArea 并非 Flickable 的子元素),则MouseArea 可以采用一种方式处理真实的鼠标事件,同时允许触摸事件穿透传递给下方的 Flickable,从而保留在触摸屏上进行轻扫操作的能力。 在这种情况下,虽然无法再通过鼠标拖动 Flickable,但这并不妨碍 Flickable 接收鼠标滚轮事件。
© 2026 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.