c++ - How to correctly notify in QQmlListProperty properties? -
whenever creating q_property
later use in qml created notify signal tell qml data changed , needs reevaluated.
now having q_property
of type qqmllistproperty<t>
how can signalize item has been modified, added or removed?
is possible?
if have list there can't propertychanged()
signal, because object reference stored remain same.
within list there won't properties, no signal emitted.
you instead use descendent of qabstractlistmodel
designed handle problem, wrapping methods append, insert etc. in own methods, emit datachanged
signal carries information necessary find changes.
of course implement similar wrapping qlist
in object, has signal inform of data change. won't integrate nicely qml real model, @ least view update automatically, when datachanged
signal received, , update necessary.
not so, if model
of view
changed directly, might happen, if manually call modelchanged()
. in case, view
miss information changed parts, recreate completely.
Comments
Post a Comment