Important: Please read the Qt Code of Conduct -

Qchart formatLabel QML

  • Hello everybody,

    I'm developing a linear chart using qml with qt creator, and I'd like to append a character to every Y axis label. For example I want append "°C" to the number 15: the final resul should be 15°C. I tried to use the following QML code, but the resul is 15?C.

    ValueAxis {
    min: 0
    max: 100
    labelFormat: "%d%1".arg("°C)

    Does someone help me?
    Many thanks in advance.

    Best Regards,

  • @Chobin
    As the documentation states, this is not supported by the ValueAxis of the QtCharts module.

    Whenever you try to use a second format specifier in .arg(), you will get a message like:

    QString::arg: Argument missing

    This is unlike the labelFormat property in the QtDataVisualization module, see for example, where the following does work:

    labelFormat: "%d \u00B0C"

    In your case, an annoying workaround would be to use a CategoryAxis instead.


                axisX: CategoryAxis {
                    min: 0
                    max: 4
                    labelsPosition: CategoryAxis.AxisLabelsPositionOnValue
                    CategoryRange {
                        label: "1 \u00B0C"
                        endValue: 1
                    CategoryRange {
                        label: "2 \u00B0C"
                        endValue: 2
                    CategoryRange {
                        label: "3 \u00B0C"
                        endValue: 3
                    CategoryRange {
                        label: "4 \u00B0C"
                        endValue: 4

    To be practical, you may need to create this one dynamically instead...

Log in to reply