Qt6 topics merged with General

How to define QML gradient object in javascript

  • This is my qtquick qml code

    function show_me(element) {
    Rectangle {
        gradient: Gradient {
            GradientStop {
                position: 0
                color: "#30cfd0"
        GradientStop {
            position: 1
            color: "#330867"
        MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onEntered: {

    The output is

    qml: QQuickGradient(0x559f18a4dd40)

    the output gives me a QtQuickGradient object

    I wonder how do I define a QtQuickGradient object in javascript?

    I want to do something like:

    var gradient = //QtQuickGradient (i don't know)
    element.gradient = gradient

    Please help me to define it

Log in to reply