QCustomPlot Discussion and Comments

Please help me guys.. i worried a lot about plotting the real time graphReturn to overview

My project is running but it is not plotting the real time graph.

here the problem
QObject::connect: No such slot MainWindow::setRange(QCPRange) in SerialPortData\mainwindow.cpp:32
QObject::connect: (receiver name: 'MainWindow')
QObject::connect: No such slot MainWindow::setRange(QCPRange) in SerialPortData\mainwindow.cpp:33
QObject::connect: (receiver name: 'MainWindow')

my code is here

//Graph plotting
    ui->Plot->addGraph(); // blue line
       ui->Plot->graph(0)->setPen(QPen(QColor(40, 110, 255)));
       QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
       ui->Plot->yAxis->setRange(-100, 100);
       // make left and bottom axes transfer their ranges to right and top axes:
       // setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
       QTimer dataTimer;
       dataTimer.start(0); // Interval 0 means to refresh as fast as possible

my slot

void MainWindow::realtimedata()
    static QTime time(QTime::currentTime());
        // calculate two new data points:
        double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
        static double lastPointKey = 0;
        if (key-lastPointKey > 0.002) // at most add point every 2 ms
          // add data to lines:
          ui->Plot->graph(0)->addData(key, qSin(key)+qrand()/(double)RAND_MAX*1*qSin(key/0.3843));
          //ui->Plot->graph(1)->addData(key, qCos(key)+qrand()/(double)RAND_MAX*0.5*qSin(key/0.4364));
          // rescale value (vertical) axis to fit the current data:
          lastPointKey = key;
        // make key axis range scroll with the data (at a constant range size of 8):
        ui->Plot->xAxis->setRange(key, 8, Qt::AlignRight);
        // calculate frames per second:
        static double lastFpsKey;
        static int frameCount;
        if (key-lastFpsKey > 2) // average fps over 2 seconds
                QString("%1 FPS, Total Data points: %2")
                .arg(frameCount/(key-lastFpsKey), 0, 'f', 0)
                , 0);
          lastFpsKey = key;
          frameCount = 0;

this is for ECG data so i want to plot a graph for that. i didnt find the solution, im new to Qt.
i dont know how to set the value of real time data for plotting a graph.

i had my image here


Please open,see and help me to resolve
i hope u all make me understand...
Thanks in advance

i mean, your connect on lines 10 and 11 dont have a slot named 'setRange' to connect to. the error is pretty obvious.

ok sir. but im new to the Qt so can u able to help me for this what should i change.. means should i change in slot?

your connect function is trying to connect a signal coming from the xAxis and yAxis QObjects to a slot called 'setRange' in your mainWindow.If this is all your code, that slot either doesnt exist or isnt marked as a slot in your header file.

first of all i like to say thank you. also want to say sorry for my communication. sir actually i have arduino device with me that produces some signal. signal is in double value. regarding that signal i want to plot a graph. i tried a lot of time but i could not do that. so i really appreciate your help here . please help me sir. im completely new to the Qt.

i created void setRange() in header file too but the graph is not plotting.
i dont know what should i add in set Range slot. code i copied from this page

here i attach my project.. have a look at this


thank you in advance.

so looking at the code in the demo, that signal is connecting xAxis and xAxis2 together so that they always have the same range. if you only have one axis, those lines arent necessary. also you didnt copy those lines correctly, which is why you are getting a compile error.

connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));

is not the same as
connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), SLOT(setRange(QCPRange)));

Sir now i added that second axis too but my graph is not plotting.

like this i added.

connect(ui->Plot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->Plot->xAxis2, SLOT(setRange(QCPRange)));
connect(ui->Plot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->Plot->yAxis2, SLOT(setRange(QCPRange)));

i give image here

no error is come.. but my graph is not plotting.
i hope u will help me till graph plot.

Thank you sir.