I just upgraded to Qgis 2.4 and there were problems with style file:
- When I load style file for Qgis <= 2.2, the color of features is
right but when I edit them, the value map (value – description pair)
is lost. - The value map I created for layers in Qgis 2.4 is not
kept in .qml style file when I choose 'save style' as 'Qgis layer
style file'.
Is this a bug in Qgis 2.4?
ADDED INFORMATION:
Sample files: http://www.mediafire.com/download/bbk02sj3jl9iwtc/test_data.7z
For line layer line.shp with 3 attributes: id, name, type – I have style file 2_2_line_style.qml generated from Qgis 2.2 which have following lines:
<edittypes>
<edittype labelontop="0" editable="0" type="0" name="id"/>
<edittype labelontop="0" editable="1" type="0" name="name"/>
<edittype labelontop="0" editable="1" type="3" name="type">
<valuepair key="first type" value="1"/>
<valuepair key="second type" value="2"/>
<valuepair key="third type" value="3"/>
</edittype>
</edittypes>
In Qgis 2.2, when I load that line layer with that style and add more lines, there will be a pop up window that allows me to enter values with a drop down list:
But in Qgis 2.4, when I load the same layer with the style file and add (create new) features, the drop down list is gone:
More over, in Qgis 2.4, when I set the value map for that line layer manually, I can get the drop down list but when I save the style as .qml and inspect the file, there isn't any key – value line like the 2.2 style file.
Best Answer
My apologies for the off-the-record answer. For me it seems you have found a bug :-)
I can reproduce your problem and did not find a solution/explanation for it...
Before ADDED INFORMATION
Strange, but I don't think it's a bug. In QGIS 2.4 I loaded a vector layer, applied a style by loading a .qml saved in QGIS 2.2, and there were no issues. I made a small change in the value map, saved it as a new .qml and loading it again went smoothly.
If you mention '... when I edit them', do you mean you select another color range from the dropdown menu? Because that's perfectly possible without losing your value-description settings. Just don't click 'Classify' because that will mess up your value map according to the classification mode you selected. But I guess you know all that...
Opening a .qml file in Notepad, you normally should see your value map at the top. Something like:
After your comment, this will probably help you further.
IF I understand what you're doing, you try to edit the values map under the Fields tab, and there you find a column called 'Edit Widget'.
I did not dig out that functionality yet, but assuming you just want to apply a style on a vector layer (nice colors and dito labels), open the Properties window of the vector layer you like to apply a style on, and do as follows.
Check out that the name of the attribute/field (stored in the .qml file) corresponds with an existing attribute in the table of your vector layer. If not, just select from the dropdown menu the column/field/attribute you like to show in your map with your style (B). In the .qml file, you can find the attribute's name in the 3th line:
If you're still happy with the style you loaded, fine! If not, edit the number of classes, choose a color ramp and a classification mode. If you're not satisfied with the lower and upper values of the generated classes, double-click in the area depicted with the red rectangle (C).
All done, you'll notice that the applied changes (color and value map) will appear as a legend.