我在Mac OS 10.8.2上使用Qt Creator 2.6.0,我在与myproject.pro.shared
相同的文件夹中创建了一个myproject.pro
文件。我将示例XML从https://qt-project.org/doc/qtcreator-2.6/creator-sharing-project-settings.html复制到myproject.pro.shared
文件。我删除了~/.config/QtProject/
文件夹,但没有myproject.pro.user
文件。
当我启动Qt Creator并打开项目文件时,不使用myproject.pro.shared
中指定的设置。例如,myproject.pro.shared
指定TabSize
为14,但在Projects>下编辑器,“编辑器设置”仍然显示“全局”,而标签大小不是14。
如何才能使其工作,以便在我第一次在新工作站上打开项目时填充默认设置?
答案 0 :(得分:5)
我错过了这一行:
<value type="bool" key="EditorConfiguration.UseGlobal">false</value>
添加后,Qt Creator默认使用具有正确设置的自定义配置。
这是我的工作,带注释的.pro.shared
文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<qtcreator>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">12</value>
</data>
<!-- "Projects > Editor" tab -->
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.UseGlobal">false</value>
<!-- "Tabs And Indentation" section -->
<value type="bool" key="EditorConfiguration.SpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="int" key="EditorConfiguration.TabSize">4</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="int" key="EditorConfiguration.PaddingMode">2</value> <!-- 0="Not At All", 1="With Spaces", 2="With Regular Indent" -->
<!-- "Typing" section -->
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> <!-- 0="None", 1="Follows Previous Indents", 2="Unindents" -->
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> <!-- 0="Never", 1="Always", 2="In Leading White Space" -->
<!-- "Cleanups Upon Saving" section -->
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<!-- "File Encodings" section -->
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> <!-- 0="Add If Encoding Is UTF-8", 1="Keep If Already Present", 2="Always Delete" -->
<!-- "Mouse and Keyboard" section -->
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
</valuemap>
</data>
</qtcreator>