//I know this code does the job for positive numbers but not for all numbers.
text: qsTr (" ") (some_positive_number)
//Is there a way that I can always display any number with its sign beside it?
CodePudding user response:
This should work fine in standard javascript:
(a - b > 0 ? " " : "") (a - b)
Note that:
There is little to no sense in using
qsTr
forNo need to calculate the difference of
a - b
thrice.
CodePudding user response:
text: (a - b > 0) ? (qsTr(" ") (a - b)) : (a - b)
//This will work fine.