Important: Please read the Qt Code of Conduct -

Table view UI update

  • Hi guys

    I am using Table view.. and trying to update my table view..

    TableView {
    model: TableModel {}
    qmlRegisterType<TableModel>("TableModel", 0, 1, "TableModel");
    QVector<QVector<QString>> m_Model;
    bool TableModel::setData(const QModelIndex &indexPos, const QVariant &value, int role)
        if(data(indexPos, role) == value)
            return false;
        QString key =;
        qDebug() << "KEY:" << key;
        m_Model.replace(indexPos.row(),{key, value});
        qDebug() << "Model Data Changed!!!" << m_Model;
        QModelIndex start = index(1,0);
        emit dataChanged(start, indexPos, {role});
        return true;
    void changeModel() {
           setData(index(1,1), "abc");

    But my UI is not getting updated
    How can I solve this issue?


  • @ashajg said in Table view UI update:

    But my UI is not getting updated

    does this mean that it still shows the old values or just displays nothing at all?

  • Hi @VRonin

    Thanks for reply!!!

    Its Still Showing same values..

  • can you try changing emit dataChanged(start, indexPos, {role}); to emit dataChanged(indexPos, indexPos);?

    Your setData doesn't seem to manage roles correctly but this is another, separate, problem

  • ok I ll try that..

Log in to reply