All the articles by this site and the original author reserves all the rights, only in the preservation of the copyright information, the original link, the original author of the case allows reprint, reproduced do not be deleted text content, and may not be used for commercial purposes. Thank you for your cooperation. original link : Configure Qt Run settings with qt.conf and Qtconfig
The previous translation of a paper on QT4 Windows program Packaging published, which mentions an important qt configuration file qt.conf, here is about this document in previous life.
(Part of this article is derived from the QT document Using qt.conf)
Often people write QT program in the use of Qt plug-ins, sometimes forget to publish the plugin with the program, sometimes do not like the QT preset plugin default path, resulting in the program can not find Plug-ins. Encounter this situation first look at the packaging published articles, by default, QT operation requires a variety of paths are written dead in the QT library, if you do not like the QT plug-in path will be used to qt.conf files, this file can be set to override QT library path.
The QT program starts with the Qlibraryinfo class to load the qt.conf file, searching in the following path order: Resource system,:/qt/etc/qt.conf Mac system will be in the resource directory, for example: assistant.app/contents/ Directory of resources/qt.conf execution files, such as: Qcoreapplication::applicationdirpath () +qdir::seperator () + "qt.conf"
qt.conf format is consistent with the INI file, you can use Qsettings to access, this file to set up a Paths option group, which can be set as follows:
Item |
Default value |
Prefix |
Qcoreapplication::applicationdirpath () |
Documentation |
Doc |
Headers |
Include |
Libraries |
Lib |
Binaries |
Bin |
Plugins |
Plugins |
Data |
. |
Translations |
Translations |
Settings |
. |
Examples |
. |
Demos |
. |
Prefix should be an absolute path, and other settings are relative to the prefix path. These items don't have to be written in, just set items that are different from the default values. For example:
[Paths]
Prefix =/some/path
Translations = i18n
In this file can also be different versions of QT set different paths, by using the form of paths/x.y.z, where x is the major version, Y is the minor version, z is the patch level number, such as:
Paths
Paths/4
paths/4.1
paths/4.2.5
The Y and z can be ignored, and the system will select the closest setting on the version, such as Qt4.5, which will match paths/4.2.5. When a matching version number is not found, a paths setting, such as Qt5.0 matching paths, is used.
Well, learn to configure this file so you don't have to worry about Plug-ins being found.
In addition, often asked Qt program font, style, etc. can not be set, in fact, QT provides a tool to configure Qt settings called Qtconfig, probably most people are not familiar with. This tool can help users set the appearance of the QT program according to their preferences. Here is a screenshot of the program screen:
This screenshot has been very descriptive, qtconfig this tool can be responsible for setting the appearance of Qt application, fonts and many other attributes, and can be real-time preview of the interface. One thing you can't see from the diagram is that the program has only a X11 version, and its configuration will be stored in the Linux user's home directory, so different users can also set different content. The document of the tool is very simple, you have to compile your own test run to better understand its function.
PS: Must add subdirectories when loading plugin plugins. For example: The plugin that supports picture display must put inside/plugins/imageformats, otherwise can't display picture