QCustomPlot Discussion and Comments

Multiple Column legendReturn to overview

hey guys,

i have a customplot with a lot of plottables(curves and graphs) and they don't all fit into my legend. The legend gets cut off at the bottom of my plot.

Is there a way to make the legend contain 2 columns? I'm still on QCP 1.3.

As i understand from:


the methods, setFillorder() and setWrap() should do what i want, right? But I don't have those. Were they added in QCP 2.0? Is there a way to do this in 1.3? My code isn't compatible with 2.0 :(

Also in QCP 1.3, the QCPLegend is derived from QCPLayoutGrid. So you can freely arrange your legend items like in any other normal grid layout.
For this, you'll probably want to manually create legend items (QCPPlottableLegendItem) and then add them to the legend with legend->addElement(row, col, item);. Note that addElement is a method of QCPLayoutGrid and allows you to specify a row and column explicitly. Whereas addItem is a method introduced by QCPLegend, and decides the row/column for you (in QCP 1.3 that's always column index 0 as you already noticed).

By the way: Transitioning code from QCP 1.3 to 2.0 shouldn't be too troublesome for most users. Did you have a look at the "backward incompatible changes" section of the changelog, and whether you're affected significantly?

I indeed did read the changelog in the meantime and I was affected by not backward compatible changes, but i adapted my code and after a full rebuild of the project i got QCP 2.0 to work.

this worked for me:

        //make legend wrap text in two columns

Thx for the answer! DerManu your the man with all the answers for this project!