This part is almost pythonically simple.
In demo2_selection.qml, our pointHandler sent the plot ID to the plugin component by assigning it directly to the component's plotId property.
plotId is a property defined on pluginFrame. Assigning to it from outside triggers QML's binding system to update the display automatically.if (shouldHandle){
<...>
if (it.hasNext()){
const feature = it.next()
iface.logMessage(feature.id)
it.close()
pluginLoader.active = true
// Pass the plot ID to the plugin component
pluginLoader.item.plotId = feature.attribute("plot_id")
return true
}
}
The plotId property is bound directly to the text of the MessageBox. Setting it from outside automatically updates the message. Ba Da Bing.
Rectangle{
id: pluginFrame
// Plot ID Property - set by parent, propagated via bindings
property string plotId: ""
Rectangle{
id: messageBoxFrame
Text{
id: messageBox
text: "Plot loaded: " + pluginFrame.plotId
}
}
}