Here is an approach that might be useful, but lacks someway the great flexibility of layouting labels directly in QGIS.
This approach makes use of
- the ability of cusom scripting QGIS and
- the ability to 'data defined override' everything in QGIS
Carry out the following few steps:
Design the Labels you desire in Inkscape.
If you have only a (very) small amount of attribute values to label, you may consider to design one label for each value [
DN 200, ... in my example]. Otherwise, for some tens or hundreds of attribute values to labels, or if these often change, it would be no great challenge to write a custom python script, that creates an *.svg file for each attribute value by simply replacing the text occurence for the attribute values directly in the svg-file:
Example code snippet (note the last line):
In my example, the width of the white background rectangle as to be adjusted too, taking the varying attribute text length into account.
Note, that the resulting svg-files are to be named according to the attribute values, something like
80.svg in my example.
In QGIS styles I add a marker line to the styles of my layer and set it up like shown below (note the 'expression'-button right beside the svg-path):
An expression depending on the attribute value enables QGIS to select the correct svg-file for each value (I think it is even possible to executing a custom function that creates the svg-files directly from the expression editor, but I did not play around with that...):
The result is shown in the screenshot below, note the 'label' near the map centre: