Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML ChartView Model
Forum Update on Monday, May 27th 2025

QML ChartView Model

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 579 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neda
    wrote on 28 Oct 2018, 11:04 last edited by neda
    #1

    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.
    Thanks

    void 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
                }        
            }
        }
    
    
    1 Reply Last reply
    0

    1/1

    28 Oct 2018, 11:04

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved