I want to set transparency for already loaded layer by taking it from canvas
QgsVectorLayer *myLayer = mpMapcanvas.layer(0); myLayer.setLayerTransparency(50); myLayer.triggerRepaint();
but get an error
invalid conversion from ‘QgsMapLayer*’ to ‘QgsVectorLayer*'
At the same time similat code at python console works great. What I'm doing wrong? Or are there any methods to convert QgsMapLayer into QgsVectorLayer?