i am trying to plot serial data using Realtime Data Demo and Qserialport Library . i am sending values from arduino as 1, 2, 3, 4, ....... to pc .after 9 , program taking values as 1, 0 , 1,1 , 1,2 ..... so plotting like that . how i read and plot datas fully as i send .

mainwindow.ccp :

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <QMessageBox>
#include <QFrame>
#include <QRect>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVector<double> data_x(101), data_y(101);
timer.start();
init_port();
init_line_plot();

QHBoxLayout *layout = new QHBoxLayout (this);
layout->setContentsMargins(5,5,5,5);
layout->addWidget(plot);

x_position = 0;

connect(serial, SIGNAL(readyRead()), this, SLOT(receive()));
}

MainWindow::~MainWindow()
{
delete ui;
serial->close();
}
void MainWindow::init_port()
{
QTextStream out(stdout);
QString portname = "/dev/ttyUSB0";
serial = new QSerialPort(portname);
if (!serial->open(QIODevice::ReadWrite))
{
QMessageBox::warning(this, "port error", "cannot open port");
}

serial->setBaudRate(QSerialPort::Baud9600);
serial->setFlowControl(QSerialPort::NoFlowControl);
serial->setParity(QSerialPort::NoParity);
serial->setDataBits(QSerialPort::Data8);
serial->setStopBits(QSerialPort::OneStop);
out <<"port opened"<<endl<<endl;
}

void MainWindow::init_line_plot()
{
// plot = new QCustomPlot (this);
//plot->addGraph();
// plot->setMinimumSize(500,500);
//plot->xAxis->setLabel("t");
// plot->yAxis->setLabel("V");


//sr

ui->customPlot->addGraph();
// ui->customPlot->setMinimumSize(500,500);
ui->customPlot->xAxis->setLabel("t");
ui->customPlot->yAxis->setLabel("V");

// plot->graph(0)->setLineWidth(1);
// plot->graph(0)->setFrameStyle(QFrame::Box | QFrame::Plain);
}

void MainWindow::receive()
{
// recieves data as ASCII string
int datalength = 1000;
char data [1000];
int bytesRead = serial->readLine(data, datalength);
data[bytesRead]='\0';


QTextStream out(stdout);
out << data << endl;
addDataPoint(atof(data));
}

void MainWindow::addDataPoint(double datapoint)
{
if (x_position>250)data_x.pop_front();
double ms = timer.elapsed();
data_x.push_back((double)ms/1000);
x_position++;
if (x_position>250) data_y.pop_front();
data_y.push_back(datapoint);

// plot->graph(0)->setData(data_x,data_y);
// plot->graph(0)->rescaleAxes();
// plot->replot();


ui->customPlot->graph(0)->setData(data_x,data_y);
ui->customPlot->graph(0)->rescaleAxes();
ui->customPlot->replot();

}