PDA

View Full Version : Setting the recommended size/sizeHint on QTextEdit



drhex
28th June 2011, 22:49
I've put 3 QTextEdits above each other in a widget using a QVBoxLayout.
The one that has input focus is supposed to be bigger than the other two, and I fix that by giving it a stretch factor of 1, while the others have a stretch factor of 0 in the layout.
That works, but the two QTextEdits that do not have any stretch become too large.
I suppose they have the default/recommended/preferred/sizeHint-size (whichever is the correct term) of 192 vertical pixels.
How can I change this default size? There does not seem to be a QWidget::setSizeHint() method, and overriding sizeHint() in a subclass did not help either (it never gets called)

wysota
28th June 2011, 23:47
I suggest you set stretch factors to 2 and 1 respectively. Setting it to 0 doesn't make much sense.

drhex
29th June 2011, 16:05
I thought that any non-essential space would be distributed such that every widget got (its own stretch)/(the sum of all stretches)*(the number of pixels to distribute)
Then, 0 would make sense as a stretch factor, as a way of saying "I don't want any extra space".
But that's apparently not how it works.
With stretch == 1 for the small QTextEdits and a large value like 100 for the big in-focus one, the small ones shrink to their minimumSize, which works fine for me.