Пользователь пока ничего не рассказал о себе

Наибольший вклад в теги

Все теги (2)

Лучшие ответы пользователя

Все ответы (1)
  • Как расположить элементы из ListModel(QML) в строго определенных местах?

    @novikovbogdan
    Я не совсем понял, надо ли добавлять элементы по одному. Если нет, то я сделал бы так:
    Repeater {
                model: mainModel
                anchors.fill: parent
                Rectangle {
                    width: 100
                    height: 100
                    color: model.color
                    z: index
                    x: model.x
                    y: model.y
                    MouseArea {
                        anchors.fill: parent
                        onClicked: Qt.quit()
                    }
                }
            }


    Если же надо добавлять элементы динамически, то:

    Repeater {
                id: repeater
                model: mainModel
                anchors.fill: parent
                property int counter: 0
                Rectangle {
                    width: 100
                    height: 100
                    color: model.color
                    visible: index<=repeater.counter
                    z: index
                    x: model.x
                    y: model.y
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            repeater.counter++
                        }
                    }
                }
            }
    Ответ написан
    Комментировать