QCustomPlot Discussion and Comments

Unexpcted color on selected QCPCurveReturn to overview

Hello,

I am using a QCPCurve (I only plot the provided points) and I try to color it on selection. The result is a blue color instead of the the black expected one:

QCPCurve * curve = new QCPCurve(xAxis, yAxis);
curve->setSelectable(QCP::stSingleData);
curve->setPen(QPen(Qt::green));
curve->setLineStyle(QCPCurve::lsNone);
curve->setScatterStyle(QCPScatterStyle::ssDisc);

QCPSelectionDecorator * decorator = new QCPSelectionDecorator();
decorator->setPen(QPen(Qt::black));
curve->setSelectionDecorator(decorator);

Do I miss something ? Thanks in advance.

Try setting decorator brush.

Thx for the reply. I got the same result, color is still blue.

Setting scatterStyle QCPSelectionDecorator

void QCPSelectionDecorator::setScatterStyle ( const QCPScatterStyle &  scatterStyle, QCPScatterStyle::ScatterProperties  usedProperties = QCPScatterStyle::spPen  ) 
seems to have done it:
    QCPCurve *curve = new QCPCurve(ui->myPlot->xAxis, ui->myPlot->yAxis);
    int points = 10;
    QVector<QCPCurveData> dataCurve(points);
    for(int i = 0; i < points; ++i)
    {
        double phi = i / static_cast<double>(points - 1) * 8 * M_PI;
        dataCurve[i] = QCPCurveData(i, qSqrt(phi) * qCos(phi), qSqrt(phi) * qSin(phi));
    }
    curve->data()->set(dataCurve, true);
    curve->setSelectable(QCP::stSingleData);
    curve->setLineStyle(QCPCurve::lsNone);
    curve->setScatterStyle(QCPScatterStyle::ssDisc);
    QCPScatterStyle myScatter;
    myScatter.setPen(QPen(Qt::red));
    curve->selectionDecorator()->setScatterStyle(myScatter, QCPScatterStyle::spPen);
    ui->myPlot->setInteraction(QCP::iSelectPlottables);
    ui->myPlot->rescaleAxes();

Thanks Eligijus, I appreciate your quick answer. That works fine.