QML ChartView Model
Unsolved
QML and Qt Quick
-
Hi,
I wanna draw chart when received data from serial port.
I used this code but I have not any point on chart.
Please guide me.
Thanksvoid SerialPort::readData() { QByteArray data = serial->read(); .... .... chartModel->addPointChart(x,y); } void ChartModel::addPointChart(double x,double y){ QStandardItem* it = new QStandardItem(); it->setData(x, ChartModel::x); it->setData(y, ChartModel::y); newChartModel->appendRow(it); }
ChartView { id: chartView anchors.fill: parent backgroundColor: "transparent" legend{ visible: false } theme: chartView.ChartThemeBlueIcy dropShadowEnabled: true animationOptions: ChartView.AllAnimations ValueAxis { id: valueAxisX min: 0 max: 50 color: "transparent" labelsFont:Qt.font({pointSize: 12}) } ValueAxis { id: valueAxisY min: 0 max: 200 color: "transparent" } HXYModelMapper{ series: lineSeries model: chartModel.newChartModel } SplineSeries { id: lineSeries name: "LineSeries" color: "blue" width: 8 VXYModelMapper{ series: lineSeries model: chartModel.newChartModel xColumn: 0 yColumn: 0 } } }