[Qt-qml] QAbstractItemModel and setData / setProperty

vineeth nvineeth at gmail.com
Tue May 24 13:17:58 CEST 2011


Hello,
  I am using a C++ QAbstractItemModel as a model for a ListView and have
implemented the setData
<http://doc.trolltech.com/4.7.1/qabstractitemmodel.html#setData>and
items<http://doc.trolltech.com/4.7.1/qabstractitemmodel.html#flags>as
indicated in the documentation to make the items editable.
  However, if I call, model.setProperty( ... ) from the delegate I get
TypeError:
Result of expression 'model.setProperty' [undefined] is not a function.
 I get the same error, even for model.setData(...) call.
   calling model.<rolename> = <new role value>  from delegate throws
read-only error.

  What is the right procedure to set a role value of a abstract item model
from a QML delegate?

  Has anybody experienced this error and pls let me know your inputs in
solving it.
  ( I have reproduced this error in the AnimalModel
example<http://doc.trolltech.com/4.7.1/declarative-modelviews-abstractitemmodel.html>,
and attached the Qt Pro.)
  Kindly share your insights.

Thanks.
--vineeth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110524/6397812f/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abstract_model_test.7z
Type: application/octet-stream
Size: 10878 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110524/6397812f/attachment.obj 


More information about the Qt-qml mailing list