I need the widget to occupy the minimum possible space, but taking into account the fact that it cannot be smaller than its contents. Its contents are two QLabel. Upper with a picture, lower with text, the length of which may be different. On the last screen, what you need to get: the red frame is the border of the widget, which should be no less, but no more than its content.
It was played with different variations of sizePolicy for the widget and all its contents, but this led to nothing. The maximum of what was achieved was the text cut off along the horizontal edges and a more or less normal looking picture, and that only because I set the minimum QLabel size in the designer for this picture. The cuot itself should understand its content, why should I myself somehow set the size of a rigid? It is not right.



QSizePolicy::FixedorQSizePolicy::Maximumfor the external widget ... but it's somewhat difficult to say without seeing the specifics ... - Fat-ZersizePolicyexplicitly definedgeometry,sizePolicyandminimumSizefor all widgets, and setsizePolicyinQSizePolicy::Fixedfor the top - should probably work ... Shl: judging by the original task, this is a good time to master theQGraphicsSceneframework instead of using a simple widget. .. - Fat-Zer