Skip to main content
added 203 characters in body
Source Link
Kadir Şahbaz
  • 78.6k
  • 57
  • 260
  • 407

Use the nameChanged signal of QgsLayerTreeNode class.

from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

It also works on groups. Therefore, you may need to check if it is a layer.

from qgis.core import QgsProject, QgsLayerTreeLayer def name_changed(node, name): if isinstance(node, QgsLayerTreeLayer): # <-- print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

Use the nameChanged signal of QgsLayerTreeNode class.

from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

Use the nameChanged signal of QgsLayerTreeNode class.

from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

It also works on groups. Therefore, you may need to check if it is a layer.

from qgis.core import QgsProject, QgsLayerTreeLayer def name_changed(node, name): if isinstance(node, QgsLayerTreeLayer): # <-- print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 
added 77 characters in body
Source Link
Taras
  • 36k
  • 7
  • 77
  • 153

Use the nameChanged signal of QgsLayerTreeNode class.

def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 
from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

Use nameChanged signal of QgsLayerTreeNode.

def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 

Use the nameChanged signal of QgsLayerTreeNode class.

from qgis.core import QgsProject def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed) 
Source Link
Kadir Şahbaz
  • 78.6k
  • 57
  • 260
  • 407

Use nameChanged signal of QgsLayerTreeNode.

def name_changed(node, name): print(f"New Name: {name}") QgsProject.instance().layerTreeRoot().nameChanged.connect(name_changed)