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 ...
随机推荐
- liferay6.1.2的API
http://docs.liferay.com/portal/6.1/javadocs/overview-summary.html
- css rgba透明度变化
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 利用js添加class
来来来,开篇点题. 分页应用.当在当前页时,分页的数字有个框之类的. 重要代码如下 <ul class="pagination"> <li><a hr ...
- How To View the HTML Source in Google Chrome
Whether you are new to the web industry or a seasoned veteran, viewing the HTML source of different ...
- 定位性能问题的18个linux命令
1.TopTop命令是一个性能监控程序,它按一定的顺序显示所有正在运行而且处于活动状态的实时进程,而且会定期更新显示结果.这条命令显示了CPU的使用率.内存使用率.交换内存使用大小.高速缓存使用大小. ...
- Linux命令: 结束命令
1)ctrl+c,退出命令 2)q,退出文件
- 如何将TNJ的源代码添加到eclipse[转]
java编程思想第四版中net.mindview.util的jar包导入 在Java编程思想第四版中需要使用net.mindview.util包,大家可以直接到http://www.mindviewi ...
- 修改MySQL数据库中表和表中字段的编码方式的方法
今天向MySQL数据库中的一张表添加含有中文的数据,可是老是出异常,检查程序并没有发现错误,无奈呀,后来重新检查这张表发现表的编码方式为latin1并且原想可以插入中文的字段的编码方式也是latin1 ...
- python文件操作-r、w、a、r+、w+、a+和b模式
对文件操作的基本步骤 f=open('a.txt','r',encoding='utf-8') data=f.read() print(data) f.close() 文件的打开和关闭使用open() ...
- 作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++
作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++. 无论各种编程语言排行榜如何变化,什么语言最赚钱,想成为真正的程序员,那么c/c++是必修课,因为几乎所有的底层都是c/c++编写的,各 ...