Important: Please read the Qt Code of Conduct -

ChartView and scrollbar

  • Hi
    I couldn't find it in any doc.

    How to make ChartView scrollable with mouse (finger) when appended data goes out of defined X axis maximum?

  • Have you tried to put it into Flickable {} ?

  • Thanks for clue, but seems like ChartView has fixed size.
    I added MouseArea to handle it - it works like dragging

    ChartView {
        id: chartView
        MouseArea {
            anchors.fill: parent
            property int lastX: 0
            property int lastY: 0
            onPressed: {
                lastX = mouse.x
                lastY = mouse.y
            onPositionChanged: {
                if (lastX !== mouse.x) {
                    chartView.scrollRight(lastX - mouse.x)
                    lastX = mouse.x
                if (lastY !== mouse.y) {
                    chartView.scrollDown(lastY - mouse.y)
                    lastY = mouse.y

  • Have you tried qchart with graphicsview framework?

  • Yes, in another project.
    QGraphicsView lays a top of QAbstaractScrollArea, so scroll bars appears there out of a box. But it requires a few lines of code to add scrolling by drag a scene.
    This time I needed QML way.

Log in to reply