[Qt-interest] Customized Label
Sean Harmer
sean.harmer at maps-technology.com
Mon Aug 9 11:27:31 CEST 2010
Hi,
On Sunday 08 August 2010 22:54:22 Sajjad wrote:
> I have a subclass of a QLabel class to make it a little customized. With
> the click event the text of the label gets changed. And the texts stored
> in the vector are of different sizes.
>
> When the text changes with the click event, sometimes some of the text get
> cropped.
>
>
> Do i have to over-ride the sizeHint() so that the label gets expanded
> dynamically to fit the text inside the label.
>
>
> In the QLabel subclass constructor i have set the sizePolicy() to
> expanding. But it seems not working.
>
>
> Any hint will be very useful.
Try calling QWidget::updateGeometry() when you change the label's text. This
tells any associated layout that the widget's sizeHint() has changed and that
it should recalculate the layout.
HTH,
Sean
More information about the Qt-interest-old
mailing list