daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Jan 13th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Access from C   to ListElement (QML) color
  2. ListModel {
  3.     id:myListModel
  4.     ListElement {name:"one" ;color:"red";objectName:"first"}
  5.     ListElement(name:"two";color:"green"}
  6. }
  7.    
  8. QObject* o=ui->declarativeView->rootObject()->findChild<QObject*>("first");
  9.   o->setProperty("color","blue");
  10.    
  11. ListModel {
  12.     id:myListModel
  13.     objectName: "model"
  14.     function setColor(index, color) {
  15.         myListModel.setProperty(index, "color", color)
  16.     }
  17.     ListElement {name:"one";color:"red"}
  18.     ListElement {name:"two";color:"green"}
  19. }
  20.    
  21. QObject* o=ui->declarativeView->rootObject()->findChild<QObject*>("model");
  22. QMetaObject::invokeMethod(o, "setColor", Q_ARG(QVariant, 0), Q_ARG(QVariant, "yellow"));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top