On 21-11-16 16:40, Martin Dobias wrote:
On Mon, Nov 21, 2016 at 6:09 PM, Richard Duivenvoorde <[email protected]> wrote:
On 2016-11-21 03:02, Martin Dobias wrote:
Ah, thanks Martin for your anwers.
Q3: looking at the possibility to add a 'Transparency slider' in the
layertree (see layer props bottom item): how difficult is it to add a
'refresh data' button (with custom refresh data code) in the layer tree
See the original pull request for some example code:
https://github.com/qgis/QGIS/pull/3170
I tried this, and indeed can create such a widget (QToolButton or
QPushBtuuon) with a handle to a layer to do things with it.
But I can only add it to a layer in the legend via the properties dialog?
Here is how to configure an embedded widget without properties dialog:
my_layer.setCustomProperty("embeddedWidgets/count", 1)
my_layer.setCustomProperty("embeddedWidgets/0/id", "transparency")
Finally one needs to call refreshLayerLegend(), e.g.:
view = iface.layerTreeView()
view.model().refreshLayerLegend(view.currentNode())
The methods from QgsLegendInterface only affect the actions in context
menu for the layer tree, they are not related to embedded widgets
functionality.
Hi Martin,
a cool thanks. Will try.
I think having this kind of functionality has a lot of potential
specially for plugin writers (examples taken from Martin's blogs or PR's):
- change transparency with a slider widget
- refresh data for this layer via a button widget
- let user choose between x predefined styles with a dropdown widget
- create a timebased subquery via a datetime-widget
- do 'something' on this layer
- layer based timeslider?
etc etc
This kind of 'components' could easily be exchanged via plugins isn't
it? Or do you envision some other exchange mechanism?
The api for using a widget via python/code could have some love I think.
Also do you think it is usefull to have the same type of widget 2 times
for a layer in the legend?
I'll try to add this new knowledge in the python cookbook too.
Thanks & Regards,
Richard Duivenvoorde
_______________________________________________
Qgis-developer mailing list
[email protected]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer