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 Updated to NodeBB v4.3 + New Features

QML ChartView Model

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 583 Views 1 Watching
  • 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 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

    • Login

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