PDA

View Full Version : flowlayout label spacing issue



SElsner
4th August 2014, 12:08
Hello,

replacing a QPubhsButton in the flowlayout example with a QLabel produces some unexpected results: the label is not vertically centred as it would be with a simple QHBoxLayout (see image of issue attached). I have tried to offset the label by adding QSize to its geometry, setting the size policy to expanding and setting the alignment to centered. But nothing did help. What am I missing? (Using 4.8.6 on CentOS 6.5)

10544

Regards

Sebastian

anda_skoa
4th August 2014, 13:53
Could be a matter of text alignment flags.

By why use that layout in the first place?

Cheers,
_

SElsner
4th August 2014, 17:07
I have set the alignment to AlignCenter but it did not help.

I am using the layout, because I have a toolbar-like widget of checkboxes and dropdowns, which I'd like to be aligned on one row (I was using a HBoxLayout for that until now). But now the widget has grown and it also needs to work on some laptop screens, which are not that wide. So it would be nice if the widgets just go to the next line if the screen is not wide enough. Do you have a better ui design for this case?

anda_skoa
5th August 2014, 09:37
If the alignment didn't work that might mean that the height of the label is less than the height of the button.

Hmm, since this is a custom layout, you could try fixing the layout's behavior so that it aligns the vertical centers of each widget of a "line".

Cheers,
_

SElsner
12th August 2014, 12:05
You are probably right. I will try make this work by first checking all the size hints of all items in a row and then moving items with smaller size hint heights. Thanks for the help.