Why is calling QSqlTablemodel::setData from const function is allowed?
I am calling QSqlTablemodel::setData from inside a const function and the compiler is not giving me an error. This doesn't seem right. Anybody know why this is allowed?
Example:
Code:
{
public:
~myClass();
private:
setRecord
(int row,
const QSqlRecord & record
) const;
mySqlTableModel *myModel;
}
{
Q_OBJECT
public:
~mySqlTableModel();
// various public and private members but no override of setRecord
}
{
database = db;
myModel = new mySqlTableModel(Q_NULLPTR, *db);
}
myClass::~myClass()
{
delete myModel;
}
bool myClass
::setRecord(int row,
const QSqlRecord & record
) const {
for (int column = 0; column < recprd.count(); column++)
{
if (!myModel->setData(myModel->index(row, column), record.value(column))) // no compile error for calling setData?
{
return false;
}
}
return true;
}
Thanks!