QCustomPlot Discussion and Comments

Access a colormap from a different method.Return to overview

Hi all:
Perhaps this is a more general C++ question. I create in one of the methods in the class a colormap

void group_ex::onDataSent(QVector<double> range,QVector<double> loc,QVector<double> linenb,QVector<double> pointnb,QVector<double> data){

QCPColorMap *dataColorMap = new QCPColorMap(ui->dataPlot->xAxis,ui->dataPlot->yAxis);


In my class I have another method to capture the mouse movement over the plot and I want to display the colormap values in this way:

void group_ex::slotMouseMove(QMouseEvent *ev){
    double xc = ui->dataPlot->xAxis->pixelToCoord(ev->pos().x());
    double yc = ui->dataPlot->yAxis->pixelToCoord(ev->pos().y());

//    qDebug() << dataColorMap->data()->data(xc,yc); <-access colormap values in this method

But I can't acces the color map I created in the other method is there a way to access the colormap via the plot? Can the colormap be created in a more global context so it is available to all the class?

I tried to declare:

QCPColorMap *dataColorMap

but it needs the plot which is only accessible once the ui is ready. Graphs can be accessed via the plot such as:


I was wondering if something similar could be done for the colormap?