4

我在 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 > Editor 下,“Editor settings”仍然显示“Global”,并且 Tab 大小不是 14。

我怎样才能让它工作,以便在我第一次在新工作站上打开项目时填充默认设置?

4

1 回答 1

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>
于 2012-12-21T16:44:41.887 回答