Qt-interest Archive, December 2006
variable-sized frameless window hint?
Message 1 in thread
I currently have a frameless window hint widget. Its content is label
filled with text that changes variably. Thus, the label will be different
sizes throughout the program, and I want to the frameless window to be
vertically shorter or taller depending on how much text there is.
I attempted to do this with the size() attribute of the label, but it didn't
seem to work. Maybe it was because I tried enabling wordwrap?
Any ideas?
--
[ signature omitted ]
Message 2 in thread
Hi,
Brian Hahn wrote:
> I currently have a frameless window hint widget. Its content is label
> filled with text that changes variably. Thus, the label will be different
> sizes throughout the program, and I want to the frameless window to be
> vertically shorter or taller depending on how much text there is.
>
> I attempted to do this with the size() attribute of the label, but it didn't
> seem to work. Maybe it was because I tried enabling wordwrap?
>
Just resize the label to its sizeHint().
label->setText(newText);
label->resize(label->sizeHint());
An alternate trick, that will work when not using wordwrap, is to put
the label in a layout. In such a case, the setText will automatically
resize the label.
Girish
--
[ signature omitted ]
Message 3 in thread
Thanks for the reply. I have this label as a child of a widget that is used
for its background. I want the background to adjust proportionally with the
widget. For example, if the label's y is 20, then I want the background's y
to be 26. If the label's y is 40, then I want the background to be 46. I
was thinking about coding the background widget to be created on the fly,
but I thought that might be inefficient. Any ideas?
"Girish Ramakrishnan" <girish@xxxxxxxxxxxxx> wrote in message
news:45741D82.8040500@xxxxxxxxxxxxxxxx
> Hi,
>
> Brian Hahn wrote:
>> I currently have a frameless window hint widget. Its content is label
>> filled with text that changes variably. Thus, the label will be
>> different sizes throughout the program, and I want to the frameless
>> window to be vertically shorter or taller depending on how much text
>> there is.
>>
>> I attempted to do this with the size() attribute of the label, but it
>> didn't seem to work. Maybe it was because I tried enabling wordwrap?
>>
>
> Just resize the label to its sizeHint().
>
> label->setText(newText);
> label->resize(label->sizeHint());
>
> An alternate trick, that will work when not using wordwrap, is to put the
> label in a layout. In such a case, the setText will automatically resize
> the label.
>
> Girish
--
[ signature omitted ]