QCustomPlot Discussion and Comments

Adding Checkboxes for every graph in the legend ?Return to overview

Hi thx for the great library.
I am trying to add checkbox for every graph in the legend so that I can do operations on them such as hide/show , add , etc. I looked up previous threads and found out that you need to either subclass QCPPlottableLegendItem or create a new QCPLayoutElement with just checkbox in it.
I am totally blank about doing it the first way, and for 2nd way, it turned out to be pretty complex with my approach. I am not sure how to draw and connect the checkbox with selectionChanged signal and then fill the checkbox upon selecting it.
Any suggestions/help would be much appreciated with some code if possible.
Thanks :)

Hi anon,
Instead of inheriting those classes, one thing you could to is set the your QCustomPlot instance's interaction to QCP::iSelectPlottables. This way, you can then use QCustomPlot->selectedGraphs().front() to get the graph that has been selected. Note that you should check the size of selectedGraphs() before using .front(). You can then perform operations on that selected graph.
Hope this helps.

Hi, I appreciate your response. I am already doing that in the backend.
But the software I'm developing has to be a bit intuitive to the user so that they know that multiple selections can be made, and I don't want him to hold [ctrl] while selecting multiple graphs.

afaik, everyone in the world who uses computers knows that ctrl+click is multiple select.

Considering ctrl+click doesn't exist would there be a method to actually get those checkboxes?