Qt5 觸控螢幕環境變數設定

2021-10-21 21:01:02 字數 2165 閱讀 6182

對於一些電阻式、單觸控觸控螢幕,可能有必要使用tslib,而不是依賴於linux多點觸控協議和事件裝置。對於現代的觸控螢幕來說,這是不必要的。可以通過將環境變數qt_qpa_eglfs_tslib設定為1來啟用tslib支援。要更改裝置,設定環境變數tslib_tsdevice或在命令列上傳遞裝置名稱。

注意,tslib輸入處理程式生成滑鼠事件並只支援單點觸控,與evdevtouch相反,它也生成真正的多點觸控qtouchevent事件。

圖1 qt官方文件在m6708-t系列arm評估套件上執行qt程式,如使用電阻屏,需要在評估板的/etc/profile檔案中,新增qt使用所需的環境變數如下所示。如使用電容屏新增如下變數是不必要的,qt程式會自動識別對應的輸入裝置,如觸控螢幕、滑鼠及鍵盤。

#tslib

export tslib_tsdevice=/dev/input/touchscreen0

export tslib_calibfile=/etc/pointercal

export tslib_conffile=/etc/ts.conf

export tslib_plugindir=/usr/lib/ts

export tslib_fbdevice=/dev/fb0

#qtexport qt_qpa_eglfs_disable_input=1

export qt_qpa_generic_plugins=

"tslib:/dev/input/touchscreen0"

export qt_qpa_platform_plugin_path=/usr/lib/plugins

export qt_qpa_platform=eglfs

export qml2_import_path=/usr/lib/qml

export qt_qpa_eglfs_tslib=1

引數解釋:

#tslib

export tslib_tsdevice=/dev/input/touchscreen0 # 指定觸控螢幕裝置

export tslib_calibfile=/etc/pointercal # 指定觸控螢幕校準檔案pointercal存放位置

export tslib_conffile=/etc/ts.conf # 指定tslib配置檔案的位置

export tslib_plugindir=/usr/lib/ts # 指定觸控螢幕外掛程式所在路徑

export tslib_fbdevice=/dev/fb0 # 指定幀緩衝裝置

#qtexport qt_qpa_eglfs_disable_input=1 # 設定為1來禁用內建輸入處理程式

export qt_qpa_generic_plugins=

"tslib:/dev/input/touchscreen0"

# 指定輸入裝置

export qt_qpa_platform_plugin_path=/usr/lib/plugins # 設定外掛程式路徑

export qt_qpa_platform=eglfs # 設定平台外掛程式

export qml2_import_path=/usr/lib/qml # 指定qml外掛程式路徑

export qt_qpa_eglfs_tslib=1 # qt啟用tslib觸控

如使用電容屏則無需配置環境,可刪除所有上述配置的環境變數。一般情況下qt會自動識別輸入裝置的型別,如無法正常識別請參考如上環境進行手動配置。

QT 觸控螢幕 驅動

要 本文主要介紹了在嵌入式 linux 系統下基於 qt embeded 的觸控螢幕驅動的設計,通過對 linux 裝置 驅動和qt embedded裝置驅動介面的工作原理和機制介紹,並結合大量源 進行分析,提出了基於qt embeded 的觸控螢幕驅動的開發方案。linux 下的裝置驅動基礎 li...

QT 觸控螢幕 TSLIB庫

tslib 是linux 觸控螢幕驅動與 qt之間的一層庫,用於支援 event 事件,在 qt中也配有 linux input 選項支援觸控螢幕,不過由於事件結構與 linux 驅動傳遞的 input event 不匹配,因而不配使用。a qt編譯 qt的編譯中需要在 configure 中新增 ...

qt觸控螢幕隱藏滑鼠指標

方法1 執行加引數 nomouse 方法2 qwidget setcursor qcursor qt blankcursor 例 this setcursor qt blankcurror 只希望在某個qwidget 或qdialog等 控制項上不出現滑鼠指標。其他視窗仍會顯示滑鼠指標。方法4 ma...