QCustomPlot Discussion and Comments

Position of legendReturn to overview


I have created a QCustomPlot that displays realtime data. Is there a way to position the legend to the upper left instead of the upper right?


The legend is a so called layout element, and it's inside the inset layout of the main axis rect. this inset layout controls the positioning of its child elements (e.g. the legend). So changing the alignment of the legend works like this:

yourPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft|Qt::AlignTop);

Note that here we inserted the 0 as index because we know the only layout element inside the inset layout is the legend, and thus has index 0.