draging a point on qtcharts



  • I am trying to drag a point on LineSeries on qtcharts. Here is my code:

    import QtQuick 2.0
    import QtCharts 2.0
    
    Item {
        anchors.fill: parent
    
        ChartView {
            title: "Two Series, Common Axes"
            anchors.fill: parent
    
            ValueAxis {
                id: axisX
                min: 0
                max: 10
                tickCount: 5
            }
    
            ValueAxis {
                id: axisY
                min: -0.5
                max: 1.5
            }
    
            LineSeries {
                id: series1
                axisX: axisX
                axisY: axisY
                onPressed: console.log("Pressed: " + point.x + ", " + point.y);   
                onReleased: console.log("Released: " + point.x + ", " + point.y);
            }
    
    
        }
        // Add data dynamically to the series
        Component.onCompleted: {
            for (var i = 0; i <= 10; i++) {
                series1.append(i, Math.random());
            }
        }
    }
    

    When I press a point on the Lineserie I can see x,y of the point I have pressed and released in the console. Both are the same though, so I cannot see the place where it released. I'd like to drag a point to another place, so if I press a point it follows the (mouse/finger on touch screen) pointer until I release on the graph. Anyone can help a bit where to start and which properties should I use?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.