依據來源: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.