QCustomPlot Discussion and Comments

Impossible to add simple Text to legendReturn to overview

QCPTextElement *tmp = new QCPTextElement(g);
tmp->setText("TOTOTOTOO");
tmp->setObjectName("toto");
tmp->setFont(s_fontUtsaah);
tmp->setTextFlags(Qt::AlignCenter);

g->legend->addElement(0,0,tmp);
g->legend->setVisible(true);

I have a white bloc shown but nothing in.

And whit this :

foreach (QCPLayoutElement *i, g->legend->elements(false))
        qDebug() << i->objectName();

I have the output =>

true    // for line g->legend->addElement(0,0,tmp);
"toto" // the correct ojject name of QCPTextElement 

Anybody have solution ?

Did you call replot?

Ah, the second example here shows that you need to set the layer of the text so it doesn't draw below the legend:
https://www.qcustomplot.com/documentation/thelayoutsystem.html

WOW first problem solved so quickly !!!

You have RIGHT !!!

Thank you very much mszo it works !

How you have found this hidden information ?