I have a problem with the export of QGIS 3 interface screenshots. I run stand-alone scripts and one of them launches QGIS and runs script.py with the following code :
mapCanvas = iface.mapCanvas()
selectedfeatures= layer.getFeatures(QgsFeatureRequest(request))
for feat in selectedfeatures:
layer.selectByIds([feat.id()])
mapCanvas.zoomToSelected(layer)
mapCanvas.refresh()
mapCanvas.saveAsImage(path)
with the command line :
qgis-bin.exe --nologo --project path_project --code script.py
But the images are not always saved (random files are saved, sometimes nothing), only the .pgw like if the interface had no time to refresh... I already read solutions like with refresh SLOTS, or QTimer but it doesn't work for me.