PDA

View Full Version : Qt layouting + QLabel's word wrap = bug?



dimuz
27th August 2007, 17:38
Hi! I'm having an issue with qt layouting system.

I noticed that if my layout contains qlabel with wordwrap turned on and if text in this label is long enough to become splitted to several lines, then all sizehints of child widgets start to be ignored (it seems) - I can resize widget to be as small as i want - up to having it to disappear (with only window caption left)!

Is this a bug or something I am missing?

To reproduce simply do the following:

1. Create a widget in designer
2. Put QLabel and QLineEdit to it. Turn word wrap on in QLabel props.
3. Put them in vertical layout (widget wide)
4. Enter some space separated words in QLabel so they make new line appear
5. Press Ctrl-R (preview) and try to resize widget to be small - size hints are ignored!

Note that this bug appears only while previewing widget in designer or running actual code using it - when you're just editing it in designer - it handles all resizing correctly and doesn't allow you to resize widget less than it's minimumSizeHint().

What do you think? is this a bug?
I'm seeing this in qt 4.3.1

dimuz
28th August 2007, 09:54
So, no ideas, guys? :)

gfunk
28th August 2007, 20:29
perhaps a screenshot (or 2) would make it clearer to people what is going on? the steps to reproduce seem a bit ambiguous.

marcel
28th August 2007, 20:32
You should be more worried about minimum sizes, not size hints, if you want the widget not to be resized below a given size.

maybe setMinimumSize(sizeHint()) can help you( it should ). but you have to write some code to do that.

Regards

dimuz
5th September 2007, 11:02
Thanks.
It helps on Linux & Windows, but doesn't help on Mac - there are a lot of empty space above and beyond label's text.
And it seems to help only occasionally - in several dialogs it works, in another - doesn't :)
Arggg :)

marcel
5th September 2007, 11:03
You must have layouts in the parents widgets in order to have the minimum sizes respected. So probably you don't have layouts set for some widgets.

Regards

dimuz
5th September 2007, 12:15
Nope, I have them :)
This makes me mad. For some reason all works in a designer, but breaks in the program run. And all because I *must* have word-wrap turned on in labels. If i turn word wrap off, things immediately start to work like they should.

qt support team told me that this is a known issue, and it cant be fixed because heightForWidth() was invented for this case. But seems like heightForWidth isn't respected too... I'm lost :)