How is it possible to render TIFF image from the path in the custom plugin? I tried to do like this:
canvas = QgsMapCanvas()
layer = QgsRasterLayer('my.tif',
'mytif',
'gdal')
QgsProject.instance().addMapLayer(layer, False)
canvas.setExtent(layer.extent())
canvas.setLayers([layer])
canvas.show()
also tried iface.addRasterLayer() and gsMapLayerRegistry.instance().addMapLayer(layer) - these two ways are definitely workable from the qgis python console however in the plugin I have warnings like
Warning: QObject::setParent: Cannot set parent, new parent is in a different thread
Warning: QObject::connect: Cannot queue arguments of type 'QList<QgsMapLayer*>'
(Make sure 'QList<QgsMapLayer*>' is registered using qRegisterMetaType().)
and nothing is rendered.
I'm trying to do it from the separate class in the plugin package if it is a necessary information.