I'm currently building a UI where I do have 3 labels that are arranged in a horizontal layout:
| textLabel | valueLabel | unitLabel |
The valueLabel
and unitLabel
are aligned right. unitLabel
has a fixed width, valueLabel
's width is variable and depends on the text length inside it. textLabel
is aligned left and fills the remaining horizontal space right up to the valueLabel
.
So, in other words, the textLabel
's width is not fixed but depends on the width of valueLabel
.
My problem: when the text inside textLabel
gets too long, it overlays the valueLabel
.
Ist there a way to hide or cut off the overlapping text? I think of something like the overflow: hidden
attribute in CSS that you can set for a <div>
, or something similar. I also tried to make use of a QLineEdit as a workaraound, but it seems that there is no way to make the QLineEdit background transparent. How can I resolve this issue? Thanks in advance!
Widgets in a layout are always managed not to overlap, so I just see no way that the
textLabel
could overlapvalueLabel
. Most likely your widgets are not managed by the layout, even if they were added to the layout. Perhaps the layout with labels is not a child of another layout, or is not set on a container widget.You're not telling us something. A self-contained test case would be good to have.
If you want a label to elide the text by finishing it with "..." instead of abruptly cutting it off, the following elided style can be used.