I have 2 shapefiles which I need to lap. The first one is city grid, and the second one representing borders of the city. Anyway, my code is:
extent = QgsRectangle()
layers = []
QgsProject.instance().addMapLayer(layerInput)
extent.combineExtentWith(layerInput)
layers.append(layerInput)
QgsProject.instance().addMapLayer(layerInputShape)
extent.combineExtentWith(layerInputShape)
layers.append(layerInputShape)
canvas.setExtent(extent)
canvas.setLayers(layers)
But for some reason it's not working, I didn't get the error message. :/