Special QGradient

  • I have a circle shape that I want to color/fill with a gradients. The center of the circle should be dark, and how further out you move in circle, the lighter the color gets (something like the sun - dark in the middle, and lighter outside).

    The gradients available are LinearGradient, RadialGradient, ConicalGradient.
    But I can't get it right to use these gradients for my purpose.

    Any idea?

  • it can be done with the radial gradient with the default pad spread. you can play with the gradient demo that is available with Qt installation and chk this out.

    set the focal points to the center, select pad spread and set the correct stop points .. you will get exactly what you've described above

  • for your widget you can set a stylesheet like this ...

    background: qradialgradient(cx:0.5, cy:0.5, radius: 1.0,
    fx:0.5, fy:0.5, stop:0 red, stop:1 white)

  • Thank you very much, I will try that.

Log in to reply