依據(jù)來源:https://doc.qt.io/qt-5/qml-qtquick-mouseevent.html
具體是在event事件或者mouse系列事件中捕獲到鼠標(biāo)事件后,用如下代碼判斷鼠標(biāo)事件是否由觸摸事件轉(zhuǎn)換而來的
if(mouseEvent->source()==Qt::MouseEventSynthesizedBySystem){
qDebug()<<"是由觸摸事件轉(zhuǎn)換而來的";
}
通過該條件的一律返回,剩下的就是不由觸摸事件生成的鼠標(biāo)事件,由此做到鼠標(biāo)與觸摸事件的分離,使得觸摸事件引起的鼠標(biāo)事件不再干擾判斷
更多信息從依據(jù)來源中抽取出來后如下,翻譯由網(wǎng)易翻譯完成。
此屬性保存鼠標(biāo)事件的源。
鼠標(biāo)事件源可用于區(qū)分真正的鼠標(biāo)事件和人工鼠標(biāo)事件。當(dāng)使用其他指向設(shè)備(如觸摸屏和圖形平板)時,如果應(yīng)用程序沒有使用實際的觸摸或平板事件,則鼠標(biāo)事件可能由操作系統(tǒng)或Qt本身合成。
取值可以是:
Qt.MouseEventNotSynthesized -最常見的值。在這些信息可用的平臺上,該值表示該事件代表來自系統(tǒng)的真正鼠標(biāo)事件。
Qt.MouseEventSynthesizedBySystem -指示鼠標(biāo)事件是由平臺從觸摸或平板事件合成的。Qt.MouseEventSynthesizedByQt -指示鼠標(biāo)事件是由Qt從未處理的觸摸或平板事件合成的。
Qt.MouseEventSynthesizedByApplication-指示鼠標(biāo)事件是由應(yīng)用程序合成的。這允許將應(yīng)用程序生成的鼠標(biāo)事件與來自系統(tǒng)或由Qt合成的鼠標(biāo)事件區(qū)分開來。
這個屬性是在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.文章來源:http://www.zghlxwxcb.cn/news/detail-648370.htmlThis property was introduced in Qt 5.7.文章來源地址http://www.zghlxwxcb.cn/news/detail-648370.html
到了這里,關(guān)于[QT/C++]如何得知鼠標(biāo)事件是由觸摸事件轉(zhuǎn)換而來的,使得鼠標(biāo)觸摸事件分離的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!