How to set Value Axis Label Format on QML from milliseconds to mm:ss?

  • Background

    I am using QtCreator and I have a file called myScopeView.qml, which represents a scope view similar to the example provided here.

    In myScopeView.qml, there is a ChartView that is updated every second with a timer so the plot changes values on X axis and Y axis.

    X axis represents time expressed in milliseconds (integer values), because of the data acquisition, and Y axis represents voltage values (characterized as integer values).


    The plot shows X axis values as integer, i.e. 123456789, but I would like to visualize the corresponding mm:ss value, i.e. 20:34. I think I have to modify the value of labelFormat.

        id: axisX
        min: 0
        max: 0
        tickCount: 5
        labelFormat: // I don't know what I have to set here


    Is it possible to set a specific value in labelFormat in order to have mm:ss visualized?


    Instead of the modification of labelFormat I tried to use a Javascript function for the conversion but this solution does not work because the conversion is achieved before the visualization and so the plot shows nothing because there is no Y values associated to new X values. That's why I am asking for a labelFormat command, but I will appreciate also a Javascript hint.

    I know that QML QtCharts has QDateTimeAxis which provides mm:ss format but I would like to convert data only for the visualization and not for other purposes.

Log in to reply