Hi all Iam trying to add legend to the print layout of a polyline that have been created using QgsLayoutItemPolyline. I managed to draw the polyline on the map composer and play with its properties, but could not add the corresponding line to the legend. Any ideas/suggestions? The code that corresponds to the legend is:
polygon2 = QPolygonF() polygon2.append(QPointF(50.0, 150.0)) polygon2.append(QPointF(150.0, 80.0)) polygon2.append(QPointF(250.0, 100.0)) polygon2.append(QPointF(10.0, 200.0)) layoutItemPolyline = QgsLayoutItemPolyline(polygon2, layout) layout.addLayoutItem(layoutItemPolyline) props = {} props["color"] = "green" props["style"] = "solid" symbol = QgsLineSymbol.createSimple(props) layoutItemPolyline.setSymbol(symbol) legend = QgsLayoutItemLegend(layout) legend.setAutoUpdateModel(False) root = legend.model().rootGroup() legend = QgsLayoutItemLegend(layout) legend.setTitle("Legend") legend.setAutoUpdateModel(False) legend.setLinkedMap(map) legend.setLegendFilterByMapEnabled(True) layout.addLayoutItem(legend) legend.attemptMove(QgsLayoutPoint(235, 36, QgsUnitTypes.LayoutMillimeters)) Thanks in advance Kind regards, Asim
_______________________________________________ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user