Qt: QAbstractItemModel and 'const'

I am trying to use QTreeView for the first time with QAbstractItemModel and have a problem instantly. The QAbstractItemModel interface declares methods as const

, assuming they will not modify data. But I want the result of the SQL query to be displayed, and to return data for the record at the specified index requires the use of QSqlQuery :: seek (), which is not a constant. Are there any "official" guidelines for using QAbstractItemModel with data that needs to be modified to get the count of items, data per item, etc.? Or should I hack C ++ with const cast?

+2


a source to share


1 answer


You can get away without any const drives by holding the pointer to QSqlQuery; your pointer won't change, only the value you point to, hence the operation will still be considered "const".



+3


a source







All Articles