xml - What is the syntax to properly use a variable in a Qt Qml XmlLIstModel query -
import qtquick 2.0 import qtquick.xmllistmodel 2.0 xmllistmodel { id: ios_elementsmodel source: "/testcode/positionersandrepeaters/positionersandrepeaters/menuitems.xml" query: "/menuitems/menuitem" xmlrole { name: "id"; query: "id/number()" } xmlrole { name: "type"; query: "type/string()" } xmlrole { name: "index"; query: "index/string()" } xmlrole { name: "verbage"; query: "verbage/string()" } xmlrole { name: "parentpageid"; query: "parentpageid/number()" } xmlrole { name: "destinationpageid"; query: "destinationpageid/number()" }
}
i using qt qml (qt quick) xmllistmodel defined above.
i have tested above code , returns of items in xml file.
i use variable filter items. such parentpageid = $myselectedpage. how do this?
the problem xmllistmodel exists represent source xml. if want have filtered list have 3 obvious options can see. first have component presents listmodel determine elements show/hide(show/hide delegate based on criteria). secondly, generate new listmodel xmllistmodel contains elements want(this can done in javascript signifigantly faster if done in c++). thirdly, have c++ layer provide initial listmodel , perform filtering when building listmodel used in qml.
if worried memory , or processing time highly recommend option 2/3 logic done in c++.
as requested, details on creating listmodel js. need have existing listmodel already. either having created 1 in advance in qml file or using dynamic qml object creation generate new one. use api found http://qt-project.org/doc/qt-4.8/qml-listmodel.html , append in elements want.
after reading comment realized filtering based on pages! @ point think best option share listmodel across components , have view determine elements show
Comments
Post a Comment