Gradient colour for lines

In the moment there is no way to colour lines with a gradient style.

First buffer your linestrings. Then you can set a gradient colour for the buffer polygons.

Here is a HowTo: How to visualize measure values along linestrings in QGIS?

Another Idea

requirement: your lines have an disinct ID

  1. Cut your linestrings in very small substrings (that it looks like a gradient).

    "______" linestring with id 1 and 100m

    "----------" every single substring must have a distinct id or serial number. Here 1 to 10 (one substring 10m). When all the linestrings have the same direction it would start with 1 und end up with the maximum count of substring.

    1. Categorize the substrings and use a color ramp: 1 green 10 (n substrings) red

Problem could be the large amount of classes, if you have very long linestrings.