QCustomPlot Discussion and Comments

Inserting widget into plotReturn to overview

Hello! The first I have to say that QCustomPlot is very great!!
Now question:
Can I insert some widget into plot, for example a checkbox into legend. I want to do a feature when user will be able to click on checkbox in order to hide or show some graph?

I've never tried it and currently don't know how it could be done, sorry. :(

If you only need this interaction with legend items to show/hide graphs, I'd recommend implementing an own legend item (QCPAbstractLegendItem, or subclass QCPPlottableLegendItem) which can be made to react to clicks accordingly and hides/shows the associated graph. This will be way easier than allowing embedding of general QWidgets.

This can be done easily by creating a new instance of your widget and adding it to the layout of the plot. Just put something like below codes in QCustomPlot Constructor:

QGridLayout * layout = new QGridLayout(this);
layout->setAlignment(Qt::AlignRight | Qt::AlignTop);

QPushButton * myBut = new QPushButton(this);

layout->addWidget(myBut , 0, 0);