Search code examples
qtqmlgradientlinear-gradientsqt5.6

Is there a way to set the linear gradient stepwith in QML


I use a linear gradient to colorize a rectangle. On my Display (480px, EGLFS) i can clearly see 16 color-steps (see picture). Is there a way to increase the number of steps to have a more fluid gradient.

bad gradient

Rectangle {
    width: 800
    height: 480
    gradient: Gradient{
        GradientStop{position: 1.0; color: "#404040"}
        GradientStop{position: 0.0; color: "black"}
    }
}

Solution

  • The problem was, that the gradient has more colors than the display can show (850 for 256). This is called colour banding (https://en.wikipedia.org/wiki/Colour_banding). After reducing the colors by using an indicated .png instead of the gradient it looks ok.