This could be done with python, but because there are various digitizing tools you will need to write code for each different tool. Here is an example of how to get the area of a polygon that is being created.
Paste this code as new script in the QGIS python console and click the run button.
canvas = iface.mapCanvas()
def __init__(self, canvas):
self.canvas = canvas
self.parent = canvas.viewport()
self.label = QLabel()
def eventFilter(self, obj, event):
mapTool = self.canvas.mapTool()
if event.type() == QMouseEvent.MouseMove and isinstance(mapTool, QgsMapToolDigitizeFeature) and mapTool.toolName() == 'Add feature':
coordinates = QgsMapMouseEvent(self.canvas, event).snapPoint()
layer = mapTool.layer()
geometryType = layer.geometryType()
if geometryType == QgsWkbTypes.PolygonGeometry:
if len(mapTool.points()) >= 2:
geometry = QgsGeometry.fromPolygonXY([mapTool.points() + [coordinates]])
crsUnits = QgsDistanceArea()
area = QgsUnitTypes.formatArea(geometry.area(), 5, crsUnits.areaUnits(), keepBaseUnit=True)
return super().eventFilter(obj, event)
eventFilter = EventFilter(canvas)
Then, type this line manually to activate the area calculation
eventFilter.start(), if you want to disable it run
I think this code will have some bugs, I'm don't know so much about Qt, so the way I display the area is by placing a label in the lower part of the Advanced Digitizing Panel. Another thing to take in account, some how QGIS doesn't let you use the QgsMapTool canvas events in the default tools (Selct, Add Feature, Identify...), so what I did to update the label every time the mouse changes it position, was to install an event filter on the canvas viewport.
This code is a very simplistic approach, so you will need to customize it for your needs.
For more complex geometry calculations threading will be a good idea.