ListView: using external model?
-
Hi all -
I've created a component (most stuff deleted):
Rectangle { ListModel { id: activityModel ListElement { parameter: "Capacity" } ListElement { parameter: "Speed" } ListElement { parameter: "Speed limits" } } Component { id: activityDelegate Text { id: paramName text: model.parameter } } ListView { id: activityView model: activityModel delegate: activityDelegate } }
I'd like to remove the model from this component, and furnish from the instantiator. I assume this is possible; how best to go about it?
Thanks...
-
Rectangle { property alias model: activityView.model Component { id: activityDelegate Text { id: paramName text: model.parameter } } ListView { id: activityView delegate: activityDelegate } }
-
@fcarney that's pretty slick. Alias properties are fairly powerful, aren't they?
Thanks for the help...
-
OK, I feel really silly asking this, because I'm the one who introduced it into this topic, but...where can I find documentation on what this line does:
text: model.parameter
Thanks...
@mzimmers here : https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#models
Note that you can now use required properties instead. Be careful that having a delegate with any required property will prevent you from using implicit context properties (like the model.parameter here) like before, you can't mix and match.
-
M mzimmers has marked this topic as unsolved on
-
M mzimmers has marked this topic as solved on