[Qgis-user] Multi-line labels and field calculator

Nathan Woodrow madmanwoo at gmail.com
Mon Oct 24 02:54:46 PDT 2011


Hi Andrew,

Just so you are aware the correct thing to use to join strings is || (double
pipe).  + is only for addition and can lead to unexpected results.

eg

stringField || '\n (' || decimalField || ' some text'

|| Will also convert non strings to strings so no need to cast.

- Nathan

On Mon, Oct 24, 2011 at 12:23 AM, Andrew Chapman <
andrew.chapman at donkagen.co.uk> wrote:

> I'm trying to combine multiple attributes into a single multi-line
> equivalent to use as a label in a shapefile.
> I create and populate a new attribute using the field calculator using an
> expression like:
>  stringField + '\n' + '(' + to string(decimalField) + ' some text'
> This successfully creates a multi-line string in the target field PROVIDED
> THAT I DON'T SAVE THE FILE. I can then use the new symbology text to
> display
> the expected label.
> If I save the layer, the multi-line string is truncated to the first line
> only and the displayed label reverts to the first line.
> The multi-line string therefore isn't saved. Is this a limitation of
> shapefiles or is it a bug?
> If it is a limitation of shapefiles, is there any other way to achieve the
> same effect?
>
> Andrew
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111024/a1e10691/attachment.html>


More information about the Qgis-user mailing list