question

laurenceh avatar image
laurenceh asked

QML help please adjust display of Pulse counter count setup page

Can someone help me with this qml, I now I need to work out how to hack qml but i'm stummped right now.

Setup Venus os 2.8 on Rpi 3B+

I have created a pulse counter service (to display my narrowboat engine hours) I am updating the 'trip' counter so that I can reset it using the console interface - it all works.

But the accumulated float rounding errors upset the display format see image here.

screenshot-2022-08-02-at-120513.png

I know I need to change the qml in "PagePulseCounterSetup.qml"

Which currently says:

               MbOK {
                        description: qsTr("Reset counter")
                        value: itemCount.value
                        editable: true
                        onClicked: {
                                itemCount.setValue(0)
                        }
                        VBusItem {
                                id: itemCount
                                bind: Utils.path(bindPrefix, "/Count")
                        }

But what do I need to change it to, to display 1 decimal place ?

I tried a few things but they did not work.

Thanks

qml
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
johanndo avatar image
johanndo answered ·

you can use 2 different ways, to set the decimals in the output

using a .format() statement or math.round() to format the value yourself

You can also use .toFixed(1)

Look in OverviewHub.qml how Victron formats the SOC and other output values.


like

value: itemCount.value.toFixed(1)

or when outputting a string:

text: itemCount.format(1)


You can also use the property

item.decimals : 1

or just when you bind an item:

decimals: 1

unit: "h"

etc.



1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

laurenceh avatar image laurenceh commented ·
@JohannDo thanks toFixed(1) worked fine.
0 Likes 0 ·

Related Resources

Additional resources still need to be added for this topic