QCustomPlot Discussion and Comments

connect between 2 customplotsReturn to overview

Hi

connect(ui->pCustomPlot->axisRect(0)->axis(QCPAxis::atBottom), qOverload<const QCPRange&>(&QCPAxis::rangeChanged), ui->pCustomPlot2->axisRect(0)->axis(QCPAxis::atBottom), qOverload<const QCPRange&>(&QCPAxis::setRange));

Why this code doesn't work?
i need connect between 2 customplot, but if 2 axisrects in one CustomPlot it's work.

Probably they don't replot in sync. For that you have signals and slots of beforeReplot/afterReplot

Thank you man!

I didn't quite understand how to do it. Can you please demonstrate an example?

I solved the problem with this code:

connect(ui->pPlot1, &QCustomPlot::beforeReplot, ui->pPlot2, [&](){
            emit ui->pPlot2->replot();
        });

hmm, why not

connect(ui->pPlot1, &QCustomPlot::beforeReplot, ui->pPlot2, &QCustomPlot::replot);
?
Seems easier. I'm not even sure your variant is formally correct, you're emitting a signal from the surrounding class, but in ui->pPlot2? Doesn't seem right.

connect(ui->pPlot1, &QCustomPlot::beforeReplot, ui->pPlot2, &QCustomPlot::replot);

This code doesn't work

i had problem when i wrote like you

see picture -https://ibb.co/BjLkM2Z

https://ibb.co/BjLkM2Z