如何使用自定义eglfs光标图集构建?

时间:2016-03-17 18:07:24

标签: qt5 embedded-linux

我试图为我的嵌入式Linux QT应用程序(QT5.5)更改eglfs鼠标光标图形。我有新的游标地图集PNG和新的JSON描述符文件,但文档相当含糊:

" ..可以通过将QT_QPA_EGLFS_CURSOR环境变量设置为JSON文件的名称来提供自定义游标地图集。该文件也可以通过Qt的资源系统嵌入到应用程序中。"

我希望尽可能保留资源系统中的所有内容,但我无法解决该问题。我是否需要一个包含JSON文件路径的特定qrc文件?我假设还需要将PNG文件添加为资源,以便将其内置到应用程序中?

如果通过资源系统添加它是一个坏主意,在哪里设置QT_QPA_EGLFS_CURSOR环境变量的正确位置?我目前正在命令行上通过" -platform eglfs&#34 ;;指定平台。这会没问题,还是我需要在构建中将平台设置为eglfs?

2 个答案:

答案 0 :(得分:1)

After much trial, error and digging around I have found the solution that I was looking for within the resource system.

Create a new resource file called "cursor.qrc", the contents of which needs to be two lines:

path/to/your/custom-cursor-atlas.png
cursor.json

The first line (path to your cursor atlas) must be relative to your resource directory.

You then need to put the JSON file (contents as described in the documentation) in the root of your resource directory. It must be called "cursor.json", and its image location line must must match the location in your new resource file and be of the format:

"image": ":/path/to/your/custom-cursor-atlas.png",

This will then include your cursor atlas in resources, and Qt will find it when your application starts.

答案 1 :(得分:0)

运行时解决方案示例:

export XDG_RUNTIME_DIR=~
export QT_QPA_EGLFS_CURSOR=~/cursor.json

cursor.json

"image": "cursor.png",

将您的自定义cursor.png地图集放入您的主目录(~),然后从那里运行Qt应用。