[QGIS-Developer] pyqgis how set filter legend map content in layer panel

Alexis R.L. alroyliz0 at gmail.com
Mon May 10 13:44:52 PDT 2021


I assume you are talking about the layout legend.

Have a look at
https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgslayoutlegend.py
for reference.


Alex


Le lun. 10 mai 2021 à 03:18, Enzo Cocca <enzo.ccc at gmail.com> a écrit :

> Hi people,
>
> How in pyqgis can I set filter legend on base map content in layer panel?
>
> I load a vector data and I would set filter legend and I would ask you
> some suggestions
>
> this my code:
>
> groupName="%s " % (self.dat)
> root = QgsProject.instance().layerTreeRoot()
> group = root.addGroup(groupName)
> group.setExpanded(False)
>
> if settings.SERVER == 'sqlite':
>             sqliteDB_path = os.path.join(os.sep, 'pyarchinit_DB_folder',
> settings.DATABASE)
>             db_file_path = '{}{}'.format(self.HOME, sqliteDB_path)
>
>             uri = QgsDataSourceUri()
>             uri.setDatabase(db_file_path)
>             uri.setDataSource('', 'pyarchinit_us_view', 'the_geom',
> cont_per_string, "ROWID")
>             layerUS = QgsVectorLayer(uri.uri(), layer_name_label_us,
> 'spatialite')
>
>             srs = QgsCoordinateReferenceSystem(self.SRS,
> QgsCoordinateReferenceSystem.PostgisCrsId)
>
>             if layerUS.isValid():
>                 style_path =
> '{}{}'.format(self.LAYER_STYLE_PATH_SPATIALITE, 'us_view.qml')
>                 layerUS.loadNamedStyle(style_path)
>                 group.insertChildNode(-1, QgsLayerTreeLayer(layerUS))
>                 QgsProject.instance().addMapLayers([layerUS], False)
>   Thanks
> E
> --
> Enzo Cocca PhD
> in "Science and Technology for Archaeology and Cultural Heritage"
>
> ISMEO
> International Association of Mediterranean and Oriental Studies
>
>
> mail: enzo.ccc at gmail.com
> cell: +393495087014
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210510/19339c7a/attachment.html>


More information about the QGIS-Developer mailing list