Qt5_qt.conf
前面翻译加工了一篇关于Qt4 Windows程序打包发布的文章 , 里面提到了一个重要的Qt配置文件qt.conf, 这里就讲讲关于这个文件的前世今生。
(本文部分内容出自Qt文档 Using qt.conf )
经常有人写Qt程序里头用到Qt的插件,有时忘记把插件与程序一起发布,有时是不喜欢Qt预设的插件默认路径, 导致程序找不到插件。 遇到这种情况先看看那篇打包发布的文章, 默认情况下Qt运行需要的各种路径都写死在Qt库里, 如果实在不喜欢Qt的插件路径就要用到qt.conf文件了, 这个文件里的设定能override Qt库的路径。
Qt程序启动时会用QLibraryInfo类载入qt.conf文件, 按下面的路径顺序搜索 :
- 资源系统, :/qt/etc/qt.conf
- Mac系统下会在资源目录, 例如:assistant.app/Contents/Resources/qt.conf
- 执行档所在目录,如:QCoreApplication::applicationDirPath()+QDir::seperator()+”qt.conf”
qt.conf的格式与ini文件一致, 可以用QSettings去访问, 这个文件里要设置一个Paths选项组,其中可以设置的项如下:
项 |
默认值 |
Prefix | QCoreApplication::applicationDirPath() |
Documentation | doc |
Headers | include |
Libraries | lib |
Binaries | bin |
Plugins | plugins |
Data | . |
Translations | translations |
Settings | . |
Examples | . |
Demos | . |
Prefix应该是一个绝对路径,其他的设定都是相对于Prefix的相对路径。 这些项不用都写进去, 只设定与默认值不同的项就可以了。例如:
[Paths]
Prefix = /some/path
Translations = i18n
在这个文件里还可以给不同版本的Qt设定不同Paths, 方法是使用Paths/x.y.z的形式, 这里的x是主版本号,y是次版本号,z是补丁级别号, 如:
Paths
Paths/4
Paths/4.1
Paths/4.2.5
其中的y和z可以忽略,并且系统会选择版本上最接近的设定,如Qt4.5这里会匹配Paths/4.2.5. 而在找不到匹配的版本号时,会使用Paths的设定, 如Qt5.0匹配Paths。
好了,学会配置这个文件就不用担心插件找不到了。
PS:加载插件plugins时一定要加上子目录。例如:支持图片显示的插件必须放到/plugins/imageformats里面,否则不能显示图片
另外,还经常有人问Qt程序的字体、风格等等能不能设置, 实际上Qt提供了一个用来配置Qt设定的工具叫qtconfig, 可能多数人还不熟悉。 这个工具就可以帮用户根据自己的喜好设定Qt程序的外观。 下面看一张程序界面的截图:
这张截图已经非常说明问题, qtconfig这个工具可以负责设定Qt应用的外观、字体等等众多属性,并且可以在界面上实时预览。 有一点从图中看不出,就是这个程序只有X11的版本, 它配置的内容会保存在Linux系统用户的家目录中, 所以不同的用户还可以设置不同的内容。 该工具的文档很简单, 大家要自己编译试运行一下才能更好的理解它的功能。
1、ZC
1.1、搜到的官网内容:
Using qt.conf (Qt5.7) http://doc.qt.io/qt-5/qt-conf.html
Using qt.conf (Qt4.8) http://doc.qt.io/qt-4.8/qt-conf.html
2、Using qt.conf (Qt5.7) http://doc.qt.io/qt-5/qt-conf.html
Using qt.conf
You can use the qt.conf
file to override paths or to specify arguments to be passed to the platform plugins.
Format and Location
The qt.conf
file is an INI text file, as described in the QSettings documentation.
QLibraryInfo will load qt.conf
from one of the following locations:
:/qt/etc/qt.conf
using the resource system- on OS X, in the Resource directory inside the application bundle, for example
assistant.app/Contents/Resources/qt.conf
- in the directory containing the application executable, i.e. QCoreApplication::applicationDirPath() + QDir::separator() + "qt.conf"
Overriding Paths
The qt.conf
file can be used to override the hard-coded paths that are compiled into the Qt library. These paths are accessible using the QLibraryInfo class. Without qt.conf
, the functions in QLibraryInfo return these hard-coded paths; otherwise they return the paths as specified in qt.conf
.
Without qt.conf
, the Qt libraries will use the hard-coded paths to look for plugins, translations, and so on. These paths may not exist on the target system, or they may not be accessible. Because of this, you may need qt.conf
to make the Qt libraries look elsewhere.
The file should have a Paths
group which contains the entries that correspond to each value of theQLibraryInfo::LibraryLocation enum. See the QLibraryInfo documentation for details on the meaning of the various locations.
Entry | Default Value |
---|---|
Prefix | QCoreApplication::applicationDirPath() |
Documentation | doc |
Headers | include |
Libraries | lib |
LibraryExecutables | libexec |
Binaries | bin |
Plugins | plugins |
Imports | imports |
Qml2Imports | qml |
ArchData | . |
Data | . |
Translations | translations |
Examples | examples |
Tests | tests |
Settings | . |
Absolute paths are used as specified in the qt.conf
file. All paths are relative to the Prefix
. On Windows and X11, thePrefix
is relative to the directory containing the application executable (QCoreApplication::applicationDirPath()). On OS X, the Prefix
is relative to the Contents
in the application bundle. For example,application.app/Contents/plugins/
is the default location for loading Qt plugins. Note that the plugins need to be placed in specific sub-directories under the plugins
directory (see How to Create Qt Plugins for details).
For example, a qt.conf
file could contain the following:
- [Paths]
- Prefix = /some/path
- Translations = i18n
Note: The backslash character is treated as a special character in INI files (see QSettings). It is therefore recommended to use forward slashes for paths on Windows as well. Otherwise, an escape character is required:
- Prefix = c:\\SomePath
Configuring Arguments to the Platform Plugins
The qt.conf
may contain a Platforms
group, whose keys are comma-delimited lists of arguments to be passed to the platform plugin. The key name is the name of the platform plugin with the first letter upper-cased followed byArguments
.
For example:
- [Platforms]
- WindowsArguments = fontengine=freetype
would cause the Windows platform plugin to use the FreeType font engine.
2.1、 [Platforms] 中的 WindowsArguments 具体别的使用方式:
ZC: 我查不到更详细的内容了...
ZC: 我现在(20160708)能查到的 另一个配置为
[Platforms]
WindowsArguments = dpiawareness=2
ZC: dpiawareness的相关信息位于: http://doc.qt.io/qt-5/highdpi.html
3、
4、
5、
Qt5_qt.conf的更多相关文章
- Nginx配置文件nginx.conf中文详解(转)
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
- Apache主配置文件httpd.conf 详解
Apache的主配置文件:/etc/httpd/conf/httpd.conf 默认站点主目录:/var/www/html/ Apache服务器的配置信息全部存储在主配置文件/etc/httpd/co ...
- redis.conf配置详细解析
# redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位, # 通常的格式就是 1k 5gb 4m 等酱紫: # # 1k => 1000 bytes # 1kb ...
- ERROR: Unable to globalize '/usr/local/NONE/etc/php-fpm.d/*.conf' 问题的解决
今天继续作大死,趟php7的配置的坑. 照例,安装了昨天的各种扩展之后,解压php7的压缩文件到 /usr/local/. 然后开始配置config的扩展: ./configure --prefix= ...
- 两个坑-Linux下Network-Manager有线未托管-DNS resolv.conf文件开机被清空
Linux里面有两套管理网络连接的方案: 1./etc/network/interfaces(/etc/init.d/networking) 2.Network-Manager 两套方案是冲突的,不能 ...
- thinkphp 3.2.3 动态修改conf配置文件
thinkphp 3.2.3 的C()方法能修改配置文件,但是是动态修改的,没有真正的更改文件. 我查了网上网友分享的方法,都不怎么合适,我就自己摸索写了一个,配置写到text.php中,我的目录如下 ...
- Mac 配置 php-fpm 时出现'/private/etc/php-fpm.conf': No such file or directory (2)
https://github.com/musicode/test/issues/5 Mac 自带 php-fpm,在终端执行 php-fpm,会报如下错误: ERROR: failed to open ...
- Tomcat下conf下server.xml的文件配置信息
Tomcat下conf下server.xml的文件配置信息,基本上不用做任何修改就可以使用,修改的地方就是host区域的一些配置,此文件设置端口为80. 注意:Tomcat配置文件中(即server. ...
- CentOS6.3 重启后/etc/resolv.conf 被还原解决办法(转)
今天一台服务器上不了网,设置了nameserver,重启后/etc/resolv.conf文件就被自动还原了,最后发现是被Network Manager修改了.解决方法:停止Network Manag ...
随机推荐
- leetcode & lintcode 题解
刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...
- JaveScript-简介
1.JaveScript:脚本语言.(弱类型语言)可以写在head,也可以写在head里,同样可以写在html外面<script src=""></script& ...
- sql 事务运用实例
------------------------------ create proc SaveFinancialProduct@FinancialName nvarchar(50),--产品名称@Yi ...
- tfs代码上传到server并下载到新位置
1.svn与git代码管理原理基本一致,基于文档管理,能看到文件代码,通过设置文件的只读属性来控制代码. 而tfs是基于sqlserver及lock来管理,看不见代码文件 2.tfs没有自己的用户管理 ...
- javascript 中function(){},new function(),new Function(),Function 摘录
函数是JavaScript中很重要的一个语言元素,并且提供了一个function关键字和内置对象Function,下面是其可能的用法和它们之间的关系. function使用方式 var foo01 = ...
- 基于GIT的管理
常用命令 git init : 初始化仓库git add 文件名 :把文件添加到暂存区git commit -m "操作记录" : 提交到仓库,设置相关操作的记录 git stat ...
- 访问Hsql .data数据库文件
一.Hsql简介: hsql数据库是一款纯Java编写的免费数据库,许可是BSD-style的协议. 仅一个hsqldb.jar文件就包括了数据库引擎,数据库驱动,还有其他用户界面操作等内容.下载地址 ...
- Java MD5校验与RSA加密
区别: MD5加密: 加密时通过原字符串加密成另一串字符串 解密时需要原加密字符串进行重新加密比较两次加密结果是否一致 RSA加密: 加密时通过原字符串生成密钥对(公钥+私钥) 解密时通过公钥和私钥进 ...
- P3435 [POI2006]OKR-Periods of Words
P3435 [POI2006]OKR-Periods of Words 题解传送门 kmp 注意:由于题目说只要A满足是2Q的前缀,所以求的不是严格的最大循环子串(20pts) 我们需要求出的是在主串 ...
- UVA1714 Keyboarding(bfs)
UVA1714 Keyboarding bfs 坑点很多的一题(由于一本通的辣鸡翻译会错题意*n). 1.多组数据 2.如果某方向上没有不同字符光标不会动 我们每次预处理出每个点向四个方向下次到达的点 ...