I am using for a option to add checkboxes in my legend next to every legend item, which are checked by default. When I uncheck a box, I want my graph to set to invisible. Here is my Plot now: https://ibb.co/ynQm4Cg.
I added my legend like this:
QCPLayoutGrid *subLayout = new QCPLayoutGrid; ui->plot_gyroscope->plotLayout()->addElement(0, 1, subLayout); subLayout->addElement(0, 0, new QCPLayoutElement); subLayout->addElement(1, 0, ui->plot_gyroscope->legend); subLayout->addElement(2, 0, new QCPLayoutElement); ui->plot_gyroscope->plotLayout()->setColumnStretchFactor(1, 0.001);
In an other thread (https://www.qcustomplot.com/index.php/support/forum/1102), somone wrote:
"wo options come to mind:
Either you subclass the QCPPlottableLegendItem and add the checkable functionality (which can then directly set its plottable's visibility), or you create a brand new QCPLayoutElement which only represents a checkbox and place that in the legend next to the plottable legend items"
I would like to use the second option, but I don't know how to implement this (I am a C++, Qt and QCustomPlot Newbie ;)). So can someone give me a hint, how to do that? Especially I cannot control how I can put this checkBoxelement right next to each of my legend items.