from qgis.core import QgsProject from qgis.analysis import QgsCompositionChecker # Load the current project project = QgsProject.instance().read() # Create an instance of QgsCompositionChecker comp_checker = QgsCompositionChecker(project) # Run the checks and print the errors found errors = comp_checker.check() print(errors)
from qgis.core import QgsProject from qgis.analysis import QgsCompositionChecker # Load the current project project = QgsProject.instance().read() # Create an instance of QgsCompositionChecker comp_checker = QgsCompositionChecker(project) # Set the maximum number of errors to return comp_checker.setMaxErrors(5) # Run the checks and print the errors found errors = comp_checker.check() print(errors)This example demonstrates how to set a limit on the number of errors found by the checker (in this case, only the first five errors will be returned). Both examples above use an import statement referencing the QGIS Python API, indicating that QgsCompositionChecker is part of the QGIS package library.