Hi Alex, Thanks for replay. Im speaking about the legend into layer panel. I'm not understand if I can set the filter legend on map when load an view with a style into layer panel. Into layer panel exist an check toolbox for this and so i would activate it when load my view or better if possible set the filter just on specific vectors.
I hope I have explained well my question E Il lun 10 mag 2021, 22:45 Alexis R.L. <alroyl...@gmail.com> ha scritto: > 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....@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....@gmail.com >> cell: +393495087014 >> >> _______________________________________________ >> QGIS-Developer mailing list >> QGIS-Developer@lists.osgeo.org >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> >
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer