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.confusing 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 ...
随机推荐
- 基于androidstudio3.0的build文件配置问题
最近,在研究APP自动化相关的东西,在搭建环境的时候,遇到的坑以及最后解决的方法,不过目前很多东西了解得还不是很细,暂时先简单的记录一下一.build配置文件 主要分为两种: 1.工程下的build配 ...
- jmeter处理带表单的接口请求
如何用jmeter处理带选项的表单接口请求 下面是用到了F12 抓包的处理方法 下图是直接手动在页面上请求的结果 下面就是采用F12抓包抓到url 和FormData 分别把上面获取的url和Form ...
- js全选反选
<style type="text/css"> table { width: 800px; text-align: left; border-collapse: col ...
- LeetCode-MinimumDepthOfBinaryTree
题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the ...
- animation-fill-mode
animation-fill-mode: none:默认值.不设置对象动画之外的状态 forwards:结束后保持动画结束时的状态,但当animation-direction为0,则动画不执行,持续保 ...
- Trove系列(一)—入门篇
概述DBaaS是目前云计算服务的重要部分,数据库作为一种特殊的应用程序,在应用中普遍存在.而其独特性不仅在于普遍性,而且其性能对应用的表现是至关重要的.数据库的通用性和重要性使得维护一个健壮的数据库实 ...
- [WPF]WPF开发方法论
纵观Windows GUI应用程序开发方法,从Windows API.MFC到Visual Basic再到.NET Framework,WPF的开发方法论是在.NET Framework方法论的基础上 ...
- ES6学习--对象属性的可枚举性( enumerable)
可枚举性(enumerable)用来控制所描述的属性,是否将被包括在for...in循环之中.具体来说,如果一个属性的enumerable为false,下面三个操作不会取到该属性.* for..in循 ...
- bzoj1633 / P2875 [USACO07FEB]牛的词汇The Cow Lexicon
P2875 [USACO07FEB]牛的词汇The Cow Lexicon 三维dp 它慢,但它好写. 直接根据题意设三个状态: $f[i][j][k]$表示主串扫到第$i$个字母,匹配到第$j$个单 ...
- 求LCA练习+部分算法复习 2017.1.22
第一题就LCA即可.不过推荐用Tarjan(最快,常数很小).然后Tarjan的时候顺便就出一个dist[i],表示i节点到根节点的距离.求出了LCA,那么两点间的距离就为dist[u] + dist ...