QLabel, how to anchor and align right ?
-
I want to create a number of QLabels that will be right aligned showing numeric data. I know how to set the text alignment, is there a way to anchor the labels by the bottom right corner so I can position each label at the same horizontal position and then they all align using the right of any data ?
-
@JonB , what I'm actually looking for I don't think exists in Qt. It seems that QLabels are positioned using the bottom left coordinate then alignment is applied which uses the geometry of the QLabel to adjust the text according to the width and x coordinate.
What I actually wanted to do is regardless of the width in the geometry I wanted to position the QLabel by the Anchor position, so if I set the anchor to bottom right and the alignment to right then any text would be displayed right of the anchor position and could never move past this position.
-
@SPlatten
No idea sinceQLabel
does not have any Anchor property.so if I set the anchor to bottom right and the alignment to right then any text would be displayed right of the anchor position and could never move past this position.
If the anchor is bottom right then how can any text be displayed to the right of that?
I don't understand, so best of luck.
-
@JonB , What I mean is that when the alignment is set to right and the anchor is specified as right that any text is always written to the same X,Y position but instead of it being displayed where each letter advances from X, that the draw function knows the anchor and the alignment is right so it adjusts the start position to allow for the left most character to be displayed where the final character right most position does not go past the initial X,Y position.
-
Hi
Im not sure either, I understand the alignment you are after.When I read it, I see like this for me