from qgis.PyQt.QtWidgets import QLabel label = QLabel() label.setText("Hello, World!")
from qgis.PyQt.QtWidgets import QLabel from qgis.core import QgsVectorLayer layer = QgsVectorLayer("C:/path/to/shapefile.shp", "Shapefile", "ogr") label = QLabel() label.setText("Shapefile Name: " + layer.name())
from qgis.PyQt.QtWidgets import QLabel from datetime import datetime now = datetime.now() label = QLabel() label.setText("Current Date and Time: " + now.strftime("%d/%m/%Y %H:%M:%S"))In all three examples, we are using the setText function to set the text to be displayed on the QLabel object. The Python QGIS library's PyQt.QtWidgets package provides support for the QLabel class.