Solved Trigger function call in ListView delegate
-
I feel as though I should know how to do this but I am struggling to know what to write in my
ListView
delegate.It's essentially a
TextInput
that I want to callselect()
on, giving it arguments that are stored in myListModel
.Assume I have
selstart
andselend
fields in my model. There isn't an option inTextInput
to bind these to properties; there is just theselect()
function. In other circumstances I would deal with this sort of thing with aConnection
to call a function in response to a property change but that doesn't seem appropriate for a model-delegate interaction. -
@J-Hilk Thanks. My problem (late last night!) with
Connections
was that I couldn't see how to make a connection to a model role. I resolved it by introducing an intermediate property in the component and binding the model role to that. I don't know if there is a better or more direct way but that seems to work.... property var start: selstart // selstart is a model role onStartChanged: doSomething() ...
-
@Bob64
If I understand you correctly, than I would personally go with either a Connection inside the delegate - like you suggested - or via a Binding
https://doc.qt.io/qt-5/qml-qtqml-binding.html -
@J-Hilk Thanks. My problem (late last night!) with
Connections
was that I couldn't see how to make a connection to a model role. I resolved it by introducing an intermediate property in the component and binding the model role to that. I don't know if there is a better or more direct way but that seems to work.... property var start: selstart // selstart is a model role onStartChanged: doSomething() ...