Tuesday, 15 January 2013

qt quick - dynamically change the model used as base for a qml item -



qt quick - dynamically change the model used as base for a qml item -

im starting work qtquick 1.1. , have designed component consisting out of pathview.

rectangle { id: pathviewelement pathview { id: pathview pathitemcount: 4 preferredhighlightbegin: 0.5 preferredhighlightend: 0.5 highlightrangemode: pathview.strictlyenforcerange model: mymodel delegate: item { width: valuetext.width height: 50 scale: 1.0-2*math.abs(pathviewelement.width/2-(x+width/2)) / pathviewelement.width opacity: scale smooth: true text { id: valuetext anchors.centerin: parent text: mymodel.value font.pointsize: 35 } } path: path { startx: 0; starty: 25 pathline { x: pathviewelement.width; y: 25;} } } }

this pathview using model called mymodel. might located in other file.

the question following: i'm using same component able alter different values. each of these values coming qml listmodel. how can dynamically alter model used in pathview (mymodel)?

also, while creating pathview can statically set model using

model: mylistmodel{}

where mylistmodel qmlfile consisting of listmodel {} declaration. when dynamically create pathview within 3rd file, myapplication.qml cannot set pathviewelement.model: mylistmodel{} compiler expecting ";" instead of {}. why this?

so how can dynamically alter model used in pathview (mymodel)?

on occurrence of respective event, can straight alter model assigned view.

eg. assuming want alter done on click of mouse button:

onclicked: { pathview.model = mynewmodel }

here, mynewmodel id new model replace with.

but when dynamically create pathview within 3rd file, myapplication.qml cannot set pathviewelement.model: mylistmodel{} compiler expecting ";" instead of {}. why this?

can state part more ?

qml qt-quick

No comments:

Post a Comment