Rectangle radius property not working with RadialGradient



  • Hey guys!
    This is my code:

    import QtQuick 2.4
    import QtQuick.Controls 1.2
    import QtGraphicalEffects 1.0
    
    ApplicationWindow {
        title: "Upload Form"
        width: 800
        height: 650
    
        RadialGradient {
            anchors.fill: parent
            gradient: Gradient {
                GradientStop { position: 0.0; color: "#ebebec" }
                GradientStop { position: 0.5; color: "#b4b4b4" }
            }
            opacity: 0.5
        }
    
        Rectangle {
            id: uploadForm
            width: 310
            height: 280
            anchors.centerIn: parent
            antialiasing: true
    		
    		radius: 10 // not working !!
    
            RadialGradient {
                anchors.fill: parent
                gradient: Gradient {
                    GradientStop { position: 0.0; color: "#373a3d" }
                    GradientStop { position: 0.5; color: "#313437" }
                }
                verticalOffset: -155
                angle: 90
            }
        }
    }
    

    But radius property of Rectangle not working when I use RadialGradient!!
    How to fix this bug?!


  • Moderators

    Hi!
    The following works:

    import QtQuick 2.4
    import QtQuick.Controls 1.2
    import QtGraphicalEffects 1.0
    
    ApplicationWindow {
        title: "Upload Form"
        width: 800
        height: 650
        visible: true
    
    
        Item {
            id: myFunkyRectangle
    
            width: 300
            height: 300
    
            RadialGradient {
                id: gradient
                anchors.fill: parent
                gradient: Gradient {
                    GradientStop { position: 0.0; color: "white" }
                    GradientStop { position: 0.5; color: "black" }
                }
                visible: false
            }
    
            Rectangle {
                id: mask
                anchors { fill: parent; margins: 18 }
                color: "black"
                radius: 30
                clip: true
                visible: false
            }
    
            OpacityMask {
                anchors.fill: mask
                source: gradient
                maskSource: mask
            }
        }
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.