0

I have a QFrame with a vertical layout and 2 QLabels: one for an image (on top) and one with actual text (on bottom).

When I have the text QLabel word wrap, it takes up more space (as it should), but the parent QFrame does not expand/resize to accommodate the extra height, and instead, the image gets cut off.

Without word wrapping, everything looks perfect.

But once word wrapping kicks in..., you can see the QFrame remains the same height despite the text taking up more space, and you see the image has "less space" and gets cut off.

I want the QFrame to get taller when the text QLabel gets taller due to word wrapping.

The QFrame's vertical layout has layoutSizeConstraint=SetMinimumSize and the sizePolicy for everything is Preferred (the default value from Qt Designer which I'm using to create the GUI). The QLabel that has the image is being scaled down to be 100px wide.

I've tried messing around with all sorts of combinations of sizePolicy changes with each object, but nothing I've tried has my desired outcome.

GayZach
  • 1
  • 1
  • Probably related to [known layout issues](https://doc.qt.io/qt-5/layout.html#layout-issues) with the rich text engine. Note that this is not only Qt specific: the problem is with dynamic layouts *and* dynamic text size allocation when word wrap is possible (where should the label wrap?). There can be workarounds, but they are always specific to each case: for instance, if you always want to keep the same width, you may use `setMaximumWidth()`. I'd suggest you to provide a [mre] and explain if/how the widget container you're using should or could be able to resize itself. – musicamante Mar 08 '23 at 23:22

0 Answers0