I would like to update weekKm and weekTime to update automatically when I change any value in m_weekKmAndTime, but I am struggling with that. I would like to acces it just like DbModel.weekKm(0)
and have value, not struggle with vars in qml and trying to get value there.
Here is my code:
in .h file:
Q_PROPERTY(QVector<QPair<int, int>> weekKmAndTime READ weekKmAndTime NOTIFY weekKmAndTimeChanged)
weekKm and weekTime are Q_INVOKABLE
in .cpp
QVector<QPair<int, int>> DataBaseModel::weekKmAndTime() const
{
return m_weekKmAndTime;
}
int DataBaseModel::weekKm(int day) const
{
return m_weekKmAndTime[day].first;
}
int DataBaseModel::weekTime(int day) const
{
return m_weekKmAndTime[day].second;
}
New contributor
percipi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.