Qt Creator `.pro.shared` files don't seem to h

2019-06-28 00:32发布

I'm using Qt Creator 2.6.0 on Mac OS 10.8.2, and I've created a myproject.pro.shared file in the same folder as myproject.pro. I copied the example XML from https://qt-project.org/doc/qtcreator-2.6/creator-sharing-project-settings.html to the myproject.pro.shared file. I deleted my ~/.config/QtProject/ folder and I do not have a myproject.pro.user file.

When I launch Qt Creator and open the project file, the settings specified in myproject.pro.shared are not used. For example, myproject.pro.shared specifies TabSize of 14, yet under Projects > Editor, "Editor settings" still says "Global", and Tab size is not 14.

How can I get this working, so that default settings are populated the first time I open a project on a new workstation?

标签: qt qt-creator
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-28 00:43

I was missing this line:

<value type="bool" key="EditorConfiguration.UseGlobal">false</value>

After adding it, Qt Creator defaults to use the custom configuration with the correct settings.

Here's my working, annotated .pro.shared file:

<?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>
查看更多
登录 后发表回答