QCustomPlot Discussion and Comments

Attach a QCPItemText to a QCPItemTracerReturn to overview

I have a QCPItemTracer and I want a QCPItemText to stick to it.

// make tracer
QCPItemTracer *phaseTracer = new QCPItemTracer(ui->cPlot);
phaseTracer->setGraph(ui->cPlot->graph(0));
phaseTracer->setGraphKey(vec.size());

// add the text label
QCPItemText *textLabel = new QCPItemText(ui->cPlot);
textLabel->setText("Text Item Demo");

How can I have the QCPItemText stick to the tracer? So that when I drag on the plot, it stays in place. I am able to set coordinates for textLabel but even that never appears correct.

help plx

Try:

textLabel->position->setParentAnchorY(phaseTracer->anchor("position"));

Thanks wincak, it works now!