QCustomPlot Discussion and Comments

fine-tune a barplotReturn to overview

https://pasteboard.co/ILQm2Mm.png
Here is the images I've been able to produce.
A couple of things:
1) How to remove this word "Graph 1"?
2) how to remove rectangles next legends? I just want to have "1: nv", etc

I've seen here on the forum that a legend is an element, but still I'd rather use
the out-of-the-box functionality with the usual legend.

Thanks.

I've been able to come this far:

bool QCPLayerable::setLayer(const QString &) no parent QCustomPlot set
bool QCPLayerable::setLayer(const QString &) no parent QCustomPlot set
void QCPLayerable::initializeParentPlot(QCustomPlot *) called with parentPlot zero
bool QCPLayerable::setLayer(const QString &) no parent QCustomPlot set
bool QCPLayerable::setLayer(const QString &) no parent QCustomPlot set
void QCPLayerable::initializeParentPlot(QCustomPlot *) called with parentPlot zero

with the following code:

QCPLegend *legend= new QCPLegend;
    legend->setParent(customPlot);
    for ( auto i= 0; i < labels.size(); ++i ) {
        PlainLegendItem *item= new PlainLegendItem(legend);
        std::string acc= labels[i].toStdString();
        acc+= " ", acc+= ticklabels[i].toStdString();
        item->setParent(customPlot);
        item->setLayer(tr(acc.c_str()));
        legend->addItem(item);
    }
    customPlot->axisRect(0)->insetLayout()->addElement(legend,Qt::AlignTop|Qt::AlignRight);

The problem is that in my custom PlainLegendItem I have always mPlottable = nullptr, and of course that does not work. What this object mPlottable is supposed to be set, if I want to have just text and no icons? I removed icons by commenting out relevant lines in the draw() method.

OK, I've solved this.
It has to be done in this order:

QCPLegend *legend= new QCPLegend;
    legend->setParent(customPlot);
    customPlot->axisRect(0)->insetLayout()->addElement(legend,Qt::AlignTop|Qt::AlignRight);
    for ( auto i= 0; i < labels.size(); ++i ) {
        PlainLegendItem *item= new PlainLegendItem(legend,bars[i]);
        item->setParent(customPlot);
        std::string acc= labels[i].toStdString();
        acc+= " ", acc+= ticklabels[i].toStdString();
        //item->setLayer(tr(acc.c_str()));
        legend->addItem(item);
    }