QCustomPlot Discussion and Comments

Multiple Real time graphs Return to overview

I am using the real-time graph example here http://www.qcustomplot.com/index.php/demos/realtimedatademo
I have two separate makeplot functions
I have two Qtimers that call a realtimedataslot and a realtimedataslot2 functions
I have set these up to be identical functions to have two QCustomPlot widgets plot the same values in real time.
The program compiles with no errors, however when running it will immediately crash. The error it gives me is this:
QCPGraph* QCustomPlot::graph(int) const index out of bounds: 0
what might be causing this error. I have made seperate Qtimers however it will only work with one real time graph

Hello Gage,
Please check if you added a graph to the secondQCustomPlot widget. At first look it seems you maybe initially added both graphs to your first plot, but you try to insert data into the second plot's graph (which does not exist).
As a tip, try to share your data container between both graphs, it will save you a lot of overhead because you are plotting the same data on both plots.

I do have the same advise as Mirza, you may not have add a graph to one of your QCustomPlot...

It turns out I had just forgotten to call the correct make plot function, thank you for the help.

hi sir, i am sudhakar, actually i have a problem in real time data plotting. i copied code from http://www.qcustomplot.com/index.php/demos/realtimedatademo this page. everything is ok than dataTimer. it is saying

C:\Users\DEBEL\Desktop\Projects\Qt2\serialtest\mainwindow.cpp:42: error: 'dataTimer' was not declared in this scope

i dont know how to resolve this issue. i hope u people will make me reply with solution.

Thanks and Regards

You need to #include <QTimer>

then in your code, before the connect

Qtimer *dataTimer = new QTimer(this);