0

I am currently creating a plugin with PyQGIS. The layers all come from a PostgreSQL database. Now I would like to include a table (without geometry) for a ValueRelation without the table appearing in the layer tree.

How can I programmatically hide a layer using PyQGIS?

By default, I load the layers as follows (without the database connection code):

uri.setDataSource("schema", "table1", None)
lyr_table1= QgsVectorLayer(uri.uri(False), "table1", 'postgres')
QgsProject.instance().addMapLayer(lyr_table1)

How do I get access to the interface of the layer tree and which method can be used for hiding?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
cc_schr_gis
  • 371
  • 1
  • 7

0 Answers0