I'm trying to set the Width of the lake's contours to zero or change the color to light blue, since the I dont want to see the black outline. The vector file is a Polygon (MultiPolygon) named vlayer2 and I have tried the following commands:


But I always get the message: ''AttributeError: 'QgsVectorLayer' object has no attribute '....' ''

enter image description here

1 Answer 1


The methods you are trying to use belong to the QgsSimpleMarkerSymbolLayer class. You need to access the symbol layer of your vector layer's renderer before you can call these methods.

The following should work for you to set the stroke color, bearing in mind that you need to pass a QColor object to this method:

vlayer2.renderer().symbol().symbolLayer(0).setStrokeColor(QColor(49, 179, 245))

Alternatively, you could set the stroke style to 'No Pen'. Setting the width to 0 will still give a 'hairline' width.


I thoroughly recommend checking out the PyQGIS Developer Cookbook which contains many useful examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.