Pregunta


¿Cómo puedo agregar un elemento a cualquier vista en tiempo de ejecución?
Por ejemplo, cuando se dispara alguna señal, la aplicación debe agregar un rectángulo a una fila específica.
Gracias,

¿Fue útil?

Solución

El uso del componente debe hacer el truco.

MySignalSource {
    Row {
        id: myRow
        anchors.fill: parent
    }

    Component {
        id: myRectComp
        Rectangle {
            width: 50
            height: 50
        }
    }

    onSignalFired: {
        var rect = myRectComp.createObject(myRow)
        rect.color = "black"
    }
}

No probado, pero debería funcionar así.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top