This is the (admittedly messy) solution I've got so far.
As I was unable to send a signal from UI file (altough QtQuick Designer accepts its declaration), I resorted to a variable registering the index of last clicked item:
// file: SettingsPageForm.ui.qml
Item {
property int clickIndex: -1
// ....
ListView {
// ...
model: dbSettingsModel
delegate: Item {
// UI graphics stuff with model.name, model,value etc...
// ...
// the delegate sets the index, the handler will reset it to -1
MouseArea { onClicked: clickIndex = model.index }
}
}
}
The implementation logic watches for the change signal:
// file: settingsPage.qml
SettingsPageForm {
...
function launchEditor( index )
{
// getRole( row, roleName) was added to C++ model because
// model properties are available inside the delegate only
editor.title = dbSettingsModel.getRole( index, "name" )
editor.value = dbSettingsModel.getRole( index, "value" )
editor.unit = dbSettingsModel.getRole( index, "unit" )
editor.minValue = dbSettingsModel.getRole( index, "minValue" )
editor.maxValue = dbSettingsModel.getRole( index, "maxValue" )
editor.open()
}
onClickIndexChanged: {
if ( clickIndex >= 0 )
launchEditor( clickIndex )
clickIndex = -1
}
}
I found no other way but to expand the C++ model (dbSettingsModel) with getRole( index, roleName), as model properties are not available outside delegates.
Overall it works, but I feel I'm overcomplicating it, I fell there must be a much cleaner way taking advantage of delegates straight inside UI deisgner.