Important: Please read the Qt Code of Conduct -

Repeater with QAbstractListModel: Repeater does not update

  • Hi,

    I am doing a plotting library. For this I made a QQuickItem which exposes a QAbstractListModel for the ticks of the axis to qml. Now I have a problem with drawing the ticks and labels, which I want to do using a repeater:

        id: root
        property int tickLength: 5
        property int tickWidth: 1
        anchors.fill: parent
        visible: true
        property var tickModel: plot.xTickModel
        Repeater {
            model: tickModel
                height: tickLength
                width: tickWidth
                x: model.PositionRole
                y: parent.height-height
                visible: true
                color: "black"
                border.width: 2
        Repeater {
            model: tickModel
            Text {
                text: PositionLabelRole
                x: PositionRole-width/2-tickWidth/2.0
                y: parent.height+8
                font.pixelSize: Style.fontSizeAxisLabel

    However, nothing is drawn on the screen. Outside, the repeater, I tested that every time the ticks are updated


    is giving the correct results. So What am I doing wrong here?

  • What I found out so far:
    The repeater never seems to call the data function of my model. Here is my setTicks Function in case the signals I emit there are relevant.:

    void TickModel::setTicks(std::vector<double> &pos,std::vector<QString> &labels) {
      beginInsertRows(QModelIndex(), 0, _tickPos.size()-1);
      _tickPos = std::move(pos);
      _tickLabels = std::move(labels);

    Is there something I need to do to get the repeater updated? Or is the problem, that I made the model available to qml as a Q_PROPERTY (see and have no notify signal?

  • This post is deleted!

  • @maxwell31 said in Problem using Repeater with QAbstractListModel:

    beginInsertRows(QModelIndex(), 0, _tickPos.size()-1);

    This should have been pos noat _tickPos, now it works

  • @maxwell31 As you are reseting the whole content of your model, you can call begineResetModel() and endResetModel() respectively at start and end of your function setTicks().

  • Thank you for the suggestion, I will change this

Log in to reply