From Qt docs
But I am not able to figure how to enable auto-resizing.The label resizes itself if auto-resizing is enabled.
Can someone please help?
Thanks a lot.
From Qt docs
But I am not able to figure how to enable auto-resizing.The label resizes itself if auto-resizing is enabled.
Can someone please help?
Thanks a lot.
Mithin
www.mithin.in
QWidget::adjustSize() does the trick, although you have to call it manually everytime you change contents of a label which is not in a layout.
And what comes to auto-resize, it's marked obsolete already in qt3's qlabel docs. I still wonder what does the above-mentioned sentence do in all over qt4's qlabel docs.
J-P Nurmi
How can I resize the label which is inside a layout ?although you have to call it manually everytime you change contents of a label which is not in a layout.
Thanks a lot.
Mithin
www.mithin.in
Hmm, QLabel should update it's size hint to correspond new contents when setting text/pixmap/..
If you are doing something custom, you could override QLabel::sizeHint() and return appropriate size for the widget (or maybe just set minimumSize). You may call QWidget::updateGeometry() to notify the layout system about the geometry change.
J-P Nurmi
will addStretch(1) do the trick ? I will probably try it and post the result.
Thanks a lot
Mithin
www.mithin.in
QBoxLayout::addStretch() will just add empty stretchable space to the end of the box layout. I don't know how the labels are even laid or what's the actual problem here, bu if you call addStretch() always when changing the pixmap of a label, you'll end up having as many spacers in the end of the layout..
J-P Nurmi
Ok Let me explain.
I have a two labels in a horizontal layout. The first label changes text (the new text is smaller in the length then the older text) on an event and therefore it should adjust its width so that the second label is next to it.
Now, in the horizontal layout at the end I add stretch.
My doubt is, will this stretch resize the label automatically ?
Since I am not reimplementing QLabel how can I achieve this resizing?
Thanks a lot.
Mithin
www.mithin.in
What exactly do you mean by "resizing a label"? You mean its content or the widget itself? Because if you only mean the widget, just set its size policy to expanding and the layout will take care of the rest. If you mean the content, then make sure scaledContents property of the label is set to true. That should suffice.
Sorry for digging this old thread but I have the same issue.
I'm trying to write my own Message box class and I need a label to be resized when anybody changes it's content. The label is in a layout but when I set text to the label it doesn't resize the dialog
C++ & AMD forever
Set a layout contstraint on the dialog's layout.
But which layoutConstraint should it be?
C++ & AMD forever
FixedSize, I guess. I'm not really sure what you are doing, so it's just a guess.
THRESHE (6th August 2008)
Bookmarks