Unsolved Table view UI update
-
Hi guys
I am using Table view.. and trying to update my table view..
TableView { model: TableModel {} } **main.cpp** qmlRegisterType<TableModel>("TableModel", 0, 1, "TableModel"); **TableModel.h** QVector<QVector<QString>> m_Model; **TableModel.cpp** bool TableModel::setData(const QModelIndex &indexPos, const QVariant &value, int role) { if(data(indexPos, role) == value) return false; QString key = m_Model.at(indexPos.row()).at(indexPos.column()-1); 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?Thanks!!!
-
@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?
-
-
can you try changing
emit dataChanged(start, indexPos, {role});
toemit dataChanged(indexPos, indexPos);
?P.S.
YoursetData
doesn't seem to manage roles correctly but this is another, separate, problem -
ok I ll try that..