Hi Everyone,
QT newbie here.
Just wondering if there is a way of designing a solution using QT for this requirement.
I have two labels.
label1
label2
Font: Arial (non monospace font)
$ amounts are variable in nature.
The label should be displayed in such a way that it appears like the . are aligned as per the below pics
Sample1
sample1.png
I tried adding the QLabels (label1 and label2) to QVBoxLayout. But it didn't help.
I noticed that input to be right-justified has a range:
//$X.XX e.g. $5.00
//$XX.XX e.g. $50.00
//$XX.XX e.g. $500.00
//$XX.XX e.g. $4999.00 (Max)
If my QString value2 contains the above strings, I count the characters e.g.
5
6
7
8 (Max)
Then I take the value1 let us say $2.36 which will always be 5 chars and do:
value1
= value1.
rightJustified(lengthOfValue2String,
QLatin1Char(' '),
true);
value1 = value1.rightJustified(lengthOfValue2String,QLatin1Char(' '), true);
To copy to clipboard, switch view to plain text mode
The problem obviously is non-monospaced Arial font which I cannot change unfortunately.
But I noticed that if I do QLatin1Char('$') instead of space, both values are aligned as per the images in my original post. But with $ instead of space which I don't want.
Is there a way of using the fillChar with $ and then make them invisible? : )
Any advice will be appreciated.
Thanks.
Bookmarks