Hi Jacek, It looks like `mBuilder` is a member of `hCapnpModel`, and the `index()` method is declared `const`, therefore all its members are const within the method body. You'll either need to declare `mBuilder` as `mutable` or remove `const` from `index()`.
-Kenton On Fri, Feb 3, 2017 at 6:01 AM, <[email protected]> wrote: > Hi Kenton, > > Thank you for your reply! But I have further difficulties. I successfully > create and load builder: > In my class: > > protected: ::capnp::MallocMessageBuilder mBuilder; > > > Then I Try to get random access to the fields (I need it for my custom > QAbstractItemModel). > In order that I use following code: > QModelIndex hCapnpModel::index(int row, int column, const QModelIndex & > parent) const > { if((column < 0) || (column >= 30)) return QModelIndex(); > capnp::SegmentArrayMessageReader lReader(mBuilder.getSegmentsForOutput()); > //capnp::SegmentArrayMessageReader > lReader(((::capnp::MessageBuilder&)mBuilder).getSegmentsForOutput()); > DokmsList::Reader lRoot = lReader.getRoot<DokmsList>(); ::capnp::List< > ::Dokms::Dokm>::Reader lList = lRoot.getDokmsList(); if((row < 0) || (row > >= lList.size())) return QModelIndex(); return createIndex(row, column); > } > In this function I need just number of rows, but in different function > (data()) I access > to the rows. So I really need some solution of the problem. > Problem occurs in line: > capnp::SegmentArrayMessageReader lReader(mBuilder.getSegmentsForOutput()); > > I got following error from VC++: > > ..\hqpanelCapnp\hcapnpmodel.cpp(141): error C2662: 'kj::ArrayPtr<const > kj::ArrayPtr<const capnp::word>> > capnp::MessageBuilder::getSegmentsForOutput(void)': cannot convert 'this' > pointer from 'const capnp::MallocMessageBuilder' to 'capnp::MessageBuilder &' > > ..\hqpanelCapnp\hcapnpmodel.cpp(141): note: Conversion loses qualifiers > > ..\hqpanelCapnp\hcapnpmodel.cpp(141): error C2512: > 'capnp::SegmentArrayMessageReader::SegmentArrayMessageReader': no > appropriate default constructor available > > > I think that (for unknown reason) VC++ thinks that mBuilder is const object > so it is > different from capnp::MessageBuilder. > > Now I am wonder how to fix it? > > > best regards > > Jacek > > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/group/capnproto. > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto.
