当前位置: 首页 > news >正文

[QT/C++]如何得知鼠标事件是由触摸事件转换而来的,使得鼠标触摸事件分离

依据来源:https://doc.qt.io/qt-5/qml-qtquick-mouseevent.html

具体是在event事件或者mouse系列事件中捕获到鼠标事件后,用如下代码判断鼠标事件是否由触摸事件转换而来的

    if(mouseEvent->source()==Qt::MouseEventSynthesizedBySystem){qDebug()<<"是由触摸事件转换而来的";}

通过该条件的一律返回,剩下的就是不由触摸事件生成的鼠标事件,由此做到鼠标与触摸事件的分离,使得触摸事件引起的鼠标事件不再干扰判断
更多信息从依据来源中抽取出来后如下,翻译由网易翻译完成。

此属性保存鼠标事件的源。

鼠标事件源可用于区分真正的鼠标事件和人工鼠标事件。当使用其他指向设备(如触摸屏和图形平板)时,如果应用程序没有使用实际的触摸或平板事件,则鼠标事件可能由操作系统或Qt本身合成。

取值可以是:
Qt.MouseEventNotSynthesized -最常见的值。在这些信息可用的平台上,该值表示该事件代表来自系统的真正鼠标事件。
Qt.MouseEventSynthesizedBySystem -指示鼠标事件是由平台从触摸或平板事件合成的。

Qt.MouseEventSynthesizedByQt -指示鼠标事件是由Qt从未处理的触摸或平板事件合成的。

Qt.MouseEventSynthesizedByApplication-指示鼠标事件是由应用程序合成的。这允许将应用程序生成的鼠标事件与来自系统或由Qt合成的鼠标事件区分开来。

这个属性是在Qt 5.7中引入的。

This property holds the source of the mouse event.

The mouse event source can be used to distinguish between genuine and
artificial mouse events. When using other pointing devices such as
touchscreens and graphics tablets, if the application does not make
use of the actual touch or tablet events, mouse events may be
synthesized by the operating system or by Qt itself.

The value can be one of:

Qt.MouseEventNotSynthesized - The most common value. On platforms
where such information is available, this value indicates that the
event represents a genuine mouse event from the system.
Qt.MouseEventSynthesizedBySystem - Indicates that the mouse event was
synthesized from a touch or tablet event by the platform.
Qt.MouseEventSynthesizedByQt - Indicates that the mouse event was
synthesized from an unhandled touch or tablet event by Qt.
Qt.MouseEventSynthesizedByApplication - Indicates that the mouse event
was synthesized by the application. This allows distinguishing
application-generated mouse events from the ones that are coming from
the system or are synthesized by Qt.

This property was introduced in Qt 5.7.

http://www.lryc.cn/news/124307.html

相关文章:

  • 消防态势标绘工具,为消防基层工作助力
  • 网络协议栈-基础知识
  • [Mongodb 5.0]聚合操作
  • Shell 变量
  • SRM订单管理:优化供应商关系
  • Unity 实现2D地面挖洞!涂抹地形(碰撞部分,方法二)
  • 简化Gerber数据传输过程丨GC PowerPlace简介
  • rust关于项目结构包,Crate和mod和目录的组织
  • 如何微调优化你的ChatGPT提示来提高对话质量
  • 微信小程序实现下拉刷新
  • 一、编程规约
  • pytest数据驱动 pandas
  • Modbus工业RFID设备在自动化生产线中的应用
  • 见证马斯克的钞能力,AI.com再次易主,OpenAI投掷1100万美金购买AI.com刚满五个月
  • linux vi/vim
  • 算法与数据结构-哈希算法
  • 企业做直播时如何选择适合自己的直播平台?
  • 【JavaWeb】实训的长篇笔记(下)
  • linux bash快捷键
  • KCC@广州开源读书会广州开源建设讨论会
  • 搜文本搜位置搜图片,1小时玩转阿里云 Elasticsearch
  • 从三个主要需求市场分析,VR全景创业的潜力发展
  • k8s 自身原理 2
  • 解决hbase节点已下线,但在status中显示为dead问题
  • 深入理解Python装饰器:解析高阶函数与代码美学
  • 构建之法 - 软件工程实践教学:每天都向前推进一点点
  • CSS transform:rotate;无效问题
  • 华为新版ENSP PRO模拟器测评:性能表现与功能扩展一览
  • BBS-个人博客项目完整搭建、BBS多人博客项目基本功能和需求、项目程序设计、BBS数据库表结构设计、创建BBS表模型
  • 智能设备管理系统对企业设备管理效果有作用吗?