10

In QGIS 2.18 there is an option to wrap text based on a certain character. What I need is to automatically wrap my text on the ' ' (space) character IF the character length exceeds the size of my legend box. Question is: how do I get an expression builder in the supplied warp box?

In this example I warped on the caracter '_' enter image description here

3 Answers 3

4

There is no way to wrap a text in the legend based on the number of characters. As you can see in wrap text in the legend, it does not support expressions. There is no expression button beside the Wrap text in legend to use . If you want to wrap the text based on space, just hit the space on you keyboard and it will be wrapped:

Before pressing the space:

enter image description here

After:

enter image description here

2
  • 2
    I don't get why they didn't allow for an expression box there. Seems like a very useful tool to haven when creating an atlas or working with many shapes in one project. Thanks for confirming though! Commented Oct 12, 2017 at 14:08
  • @HannesLedegen you can add a feature request to the QGIS developer team. Please refer to this answer on how to add a feature request: gis.stackexchange.com/a/208149/63384 Commented Oct 13, 2017 at 3:44
1

I've found a bit of a work around for this - if you go into 'legend items' -> double click a layer to amend the text -> hit 'enter' on where you would like the text to wrap it starts a new line so you can manually create the wraps (bit tedious if you have a lot of layers showing)

0

As was brought to my attention in the corresponding feature request on GitHub, there is a very similar feature that made it into QGIS 3.44 (set to become LTR at the end of February 2026).

You can now use "Item Properties - Word Wrapping - Maximum length" to wrap text at a certain length (not number of characters).

See some more info in the pull request (including video) and the word wrapping documentation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.