I had this exact "problem" today : > Usually the data is contained in a non-const object, presumably in the model itself, so the pointer isn't ordinarily pointing to an immutable object.
sure, but the methods that generally call createIndex (QAbstractItemModel::index for instance) are const, so your members are const too, so you have to const_cast<T*>(&m_data.getMyObject(row, column)); On Tue, Nov 27, 2018 at 6:50 PM Konstantin Shegunov <[email protected]> wrote: > Hi, > > On Tue, Nov 27, 2018 at 7:41 PM Matthew Woehlke <[email protected]> > wrote: > >> But... why *isn't* there such an overload? > > > Your object is const, so the implicit cast to void * fails. > > >> Is there any reason not to add one? > > > I'd say the question is rather, is there really a reason to add one? > > Usually the data is contained in a non-const object, presumably in the > model itself, so the pointer isn't ordinarily pointing to an immutable > object. > Do you need to enforce the const? > > Kind regards. > _______________________________________________ > Development mailing list > [email protected] > https://lists.qt-project.org/listinfo/development >
_______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
