2

I would like to have my visible label text broken, which is too long. enter image description here

I found some solution here:

How to split text attribute by characters in QGIS?

but applying the expression to my example:

  left( "Text", strpos( "Text" ,'-'))

I am getting only B3-, whereas another part of the text is gone. I need the visible label like this:

B3-24F
DP &\PSP2

instead of

B3-24F DP&\PSP2

How can I do it?

ahmadhanb
  • 40,826
  • 5
  • 51
  • 105
Geographos
  • 4,087
  • 2
  • 27
  • 88

2 Answers2

3

Your expression does exactly what it is supposed to be doing. I guess you mixed up the terms "split" and "wrap".

Go to your label properties and navigate to "formatting". Then fill "wrap on character" with -:

enter image description here

Also check out the other options available there ;)

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
3

The labels displayed in your map, and the labels displayed in the text of your question are different. The labels in the map shows B3- 24F DP & \PSP2, and the labels in the text of your question shows B3-24F DP&\PSP2. The former text contains more spaces compared with the latter text.

Anyway whatever the case, you need to use Wrap lines to and specify the number of characters you want, and then choose Minimum line length in the drop-down menu.

In this example, I used 6 characters. Here is the settings, and the final output:

enter image description here

ahmadhanb
  • 40,826
  • 5
  • 51
  • 105