最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】QFontDatabase: Cannot find font directory XXX/lib/fonts – is Qt installed correctly?

工作和技术 crifan 5459浏览 0评论

【问题】

通过buildroot配置编译好qtopia后,下载到开发板上,配置好环境变量:

export QWS_DISPLAY="LinuxFb:mmWidth480:mmHeight272:0"
export QWS_SIZE="480×272"
export LD_LIBRARY_PATH=/usr/lib

然后去运行demo程序,出现:

# /usr/demos/chip/chip -qws
QFontDatabase: Cannot find font directory /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr/lib/fonts – is Qt installed correctly?
Aborted

【解决过程】

1.由于之前已经折腾了关于qtopia的配置并编译,所以,对于qt的官方的文档中的这部分说明:

http://qt.nokia.com/doc/qtopia4.3/running-qtopia.html

“Environment Settings to Run Qtopia

There are no specific environment variables required to run Qtopia, however there are some that can be set to control Qtopia’s features.

If you specified -no-rpath you will need to set LD_LIBRARY_PATH so that the libraries can be found.

Qtopia does not require PATH to be set but third party applications may expect it to include <prefix>/bin.

You may wish to set some environment variables to configure Qtopia Core. You may also need to set QTOPIA_PHONE_DEVICE. See Qtopia Environment Variables for details on how to set environment variables.

应该还算理解了其意思,说的是,如果你当初编译qtopia的时候,在./configure 中加了-no-rpath,根据说明:

“    -no-rpath ………. Do not use the library install path as a runtime
                         library path.
+ -rpath …………. Link Qt libraries and executables using the library
                         install path as a runtime library path. Equivalent
                         to -R install_libpath

意思就是,不要使用你的安装路径,即-prefix指定的路径,如果没用-prefix指定,那么就是默认的/usr/local/Trolltech/QtEmbedded-4.5.3:
“    -prefix <dir> …… This will install everything relative to <dir>
                         (default /usr/local/Trolltech/QtEmbedded-4.5.3)”

而我这里当初配置的是-prefix $(TARGET_DIR)/usr,即 -prefix /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr意思是将qtopia安装到buildroot中rootfs中的usr下面。

并且,按照其说明,不需要配置其他环境变量了,只是由于编译的时候,加了-no-rpath,所以需要配置一下对应的LD_LIBRARY_PATH,这里由于之前配置成/home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr,buildroot中make的时候,编译qt并make install到对应的rootfs文件夹的usr下面了,而现在rootfs已经烧写到板子了,已经进了rootfs了,所以要配置成/usr/lib,以便qt程序运行的时候,能找到对应的库文件。

所以,其他参数,应该就没有再需要配置的了,应该就可以工作的了。

而且,关于

http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html

中,也介绍了,关于qt-core的一些环境变量,主要是QWS_DISPLAY,我这里,也按照网上别人的帖子和官方文档中的说明,去配置了:

export QWS_DISPLAY="LinuxFb:mmWidth480:mmHeight272:0"
export QWS_SIZE="480×272"

export QWS_DISPLAY="LinuxFb:/dev/fb0"
了,但是,还是无法工作,运行测试程序,还是显示错误:

# /usr/demos/mainwindow/mainwindow -qws
QFontDatabase: Cannot find font directory /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr/lib/fonts – is Qt installed correctly?

最后,无意间,在网上看到别人的帖子:

http://hi.baidu.com/a263238386/blog/item/6ff055dda933033e5882dd32.html

发现有个关于qt font的环境变量:export QT_QWS_FONTDIR=$QTDIR/lib/fonts

所以,自己就去加了一下:

export QT_QWS_FONTDIR=/usr/lib/fonts

export LD_LIBRARY_PATH=/usr/lib
或者

export QTDIR=/usr
export LD_LIBRARY_PATH=$QTDIR/lib
export QT_QWS_FONTDIR=$QTDIR/lib/fonts

结果,qt的demo程序就可以运行了,呵呵。

总结一下解决方法就是:

正确设置QT_QWS_FONTDIR,指定qt的font具体路径,这样程序才能找到font。

此处我的是

export QT_QWS_FONTDIR=/usr/lib/fonts

实际结果表明,这些相关的qt的环境变量,是必须的,要指定好对应的位置,让qt能找到qt的lib和font等必须的资源,才可以运行qt的demo和example的。

其他的参数,好像这个,可有可无的:

export QT_PLUGIN_PATH=$QTDIR/plugins/

如果用到鼠标和键盘,那估计

http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html

中的QWS_MOUSE_PROTO和QWS_KEYBOARD 也要配置好的。有空再去试试。

【提示】

1.关于-prefix参数,为何不用qt默认的配置的/usr 而去自己修改为$(TARGET_DIR)/usr:

因为默认的qt.mk中原先配置的是 -prefix /usr,会去讲qtopia安装到我buildroot所在Linux的/usr下面,很弱智的,这样,你buildroot中去make,最后的qtopia的make install会去将生成的qt的东西,用于arm板子的qt的东西,会安装到你当前X86的PC上的Linux下的/usr中,这不扯淡的吗。。

所以,才会去在buildroot中package/qt.mk中,配置成QT_CONFIGURE += -prefix $(TARGET_DIR)/usr

【引用】

1。Online Reference Documentation

http://qt.nokia.com/doc/qtopia4.3/index.html

2.Qtopia Developer Resources

http://qt.nokia.com/doc/qtopia4.3/index.html

3.Running Qtopia
http://qt.nokia.com/doc/qtopia4.3/running-qtopia.html

4.Qtopia Core Environment Variables
http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html

5.QT 4.5.2 嵌入式开发平台的搭建

http://hi.baidu.com/a263238386/blog/item/6ff055dda933033e5882dd32.html

6.环境变量QWS_DISPLAY

http://fanzhichao.blog.hexun.com/23669000_d.html

转载请注明:在路上 » 【已解决】QFontDatabase: Cannot find font directory XXX/lib/fonts – is Qt installed correctly?

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.149 seconds, using 22.13MB memory