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.

enter image description here enter image description here What you need to get

  • probably you want to install QSizePolicy::Fixed or QSizePolicy::Maximum for the external widget ... but it's somewhat difficult to say without seeing the specifics ... - Fat-Zer
  • I can paint in more detail, but I do not know what exactly is required for specifics. The red dot is the image inside the pixmap that is inside the labelImagePoint. The cropped figures (0: 1), which is below the red dot, are the text inside the labelTextGamePoint, the text has been cropped (this is the problem). Both of them are in the widget, which is drawn on top of another widget - the main one (in the picture it looks like a map). - FliXis pm
  • All I need is for the external widget (dot and text) to be maximally connected to each other (which is happening now), but not to cut the text. And that the very border of this widget would be the minimum size. Added another screen of what I would like to receive. Red - the border of the widget. The border should be minimal, because the widget implies clickability in its area. - FliXis pm
  • sizePolicy explicitly defined geometry , sizePolicy and minimumSize for all widgets, and set sizePolicy in QSizePolicy::Fixed for the top - should probably work ... Shl: judging by the original task, this is a good time to master the QGraphicsScene framework instead of using a simple widget. .. - Fat-Zer
  • It does not help that I did not put it at the top widget, the result is the cut text. I have already tried QGraphicsScene, they have their own troubles and problems in my case, the current version is still the most working one. - FliXis

0