tags:

views:

39

answers:

1

Hello.

I'm trying to use a QTreeView for a first time, with a QAbstractItemModel. And instantly it's a problem: QAbstractItemModel interface declares methods as 'const', assuming they will not change data. But i want a result of SQL query displayed, and returning data for a record with specified indeq REQUIRES to use QSqlQuery::seek() that is a non-const. Is it any 'official' guideline to use a QAbstractItemModel with data that MUST be changed in order to get number of items, data per item etc? Or i must hack C++ with const casts?

+2  A: 

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

Michael Aaron Safyan
Shame to me -_-. Thanks.
Eye of Hell