Unsolved QML conditional binding ShapePath fillGradient
-
Hi
I have two types of gradient Linear and Radial and want to use one or another depending on variable from model.
In case of simple value binding this works:color: (some_condition ? "blue" : "red")
Or javascript notation
color: { if ( someObj != null ) { return someObj.color; } else { return "black"; } }
But in case of setting gradient to fill shape neither of these works:
fillGradient: (gradient_type==0 ? RadialGradient { centerX: shape.width*gradient_radial[0]/100; centerY: shape.height*gradient_radial[1]/100; focalX: shape.width*gradient_radial[2]/100; focalY: shape.height*gradient_radial[3]/100; centerRadius: shape.width/2*gradient_radial[4]/100; GradientStop { position: gradient_step_color[0]/100.0; color: gradient_color[0] } GradientStop { position: gradient_step_color[1]/100.0; color: dimmer_step_color } GradientStop { position: gradient_step_color[2]/100.0; color: gradient_color[2] } } : null )
fillGradient: { if (gradient_type==0) { return RadialGradient { centerX: shape.width*gradient_radial[0]/100; centerY: shape.height*gradient_radial[1]/100; focalX: shape.width*gradient_radial[2]/100; focalY: shape.height*gradient_radial[3]/100; centerRadius: shape.width/2*gradient_radial[4]/100; GradientStop { position: gradient_step_color[0]/100.0; color: gradient_color[0] } GradientStop { position: gradient_step_color[1]/100.0; color: dimmer_step_color } GradientStop { position: gradient_step_color[2]/100.0; color: gradient_color[2] } } } else { return null; } }
Is there a way to make it work? would it work with function returning Gradient ?
Best,
Marek