Dieser Teil ist fast pythonisch einfach.
In demo2_selection.qml hat unser pointHandler die Plot-ID an die Plugin-Component gesendet, indem er sie direkt der plotId-Property der Component zugewiesen hat.
plotId ist eine Property, die auf pluginFrame definiert ist. Die Zuweisung von außen löst QMLs Bindungssystem aus, das die Anzeige automatisch aktualisiert.if (shouldHandle){
<...>
if (it.hasNext()){
const feature = it.next()
iface.logMessage(feature.id)
it.close()
pluginLoader.active = true
// Übergeben Sie die Plot-ID an die Plugin-Component
pluginLoader.item.plotId = feature.attribute("plot_id")
return true
}
}
Die plotId-Property ist direkt an den Text der MessageBox gebunden. Wenn sie von außen gesetzt wird, aktualisiert sich die Anzeige automatisch. Ba Da Bing.
Rectangle{
id: pluginFrame
// Plot ID Property - von Parent gesetzt, propagiert über Bindungen
property string plotId: ""
Rectangle{
id: messageBoxFrame
Text{
id: messageBox
text: "Plot loaded: " + pluginFrame.plotId
}
}
}