PDA

View Full Version : What sizeHint is set by?



Stolen
30th September 2017, 20:12
Hi all!
I build my UI and base it on QSizePolicy of widgets (but not on layouts' stretch factors). Therefore I use enum QSizePolicy::Policy. The latter refers to QWidget::sizeHint() explaining which constant of the enumeration I should use how it relates that sizeHint. Hence, I seem to be aware of sizeHint's value and be able to set it somehow. The problem is I don't clearly understand what sizeHint is, what it is set by and whether I'm expected to set it manually.
So, sizeHint is some characteristic of both QLayoutItem and QWidget. In QWidget it holds the recommended size for the widget, in QLayoutItem it returns the preferred size of this item. As I see, there's no way to set it directly.
I need to realize, which layouts' and widgets' functions influence the value of sizeHint.
Is there a sense to access it straightly?

In addition, the task I wish to implement probably depends on the above knowledge. Anyway I don't know how it can be done up to now. To be short, I want a widget placed into QGridLayout and spanned there along 2x2 cells keep given minimum size, but appear bigger with another concrete size in the the opening window just after it's shown. I tried setBaseSize() (+ combined it with adjustSize()), QSizePolicy::Expanding, setVerticalStretch(1) & setHorizontalStretch(1) (when appropriate stretches of neighbour single layout's widget are equal to 0), setFixedWidth() & setFixedHeight(). However, I could't reach behaviour I expect.

Hope, you could help...