Form setup:
QSplitter (highlighted on the image) that contains QTreeWidget (left) and QTableWidget (right):

Non-default properties of these two widgets within QSplitter:
-
QTreeWidgetminimumSize / Width = 150
-
QTableWidgetminimumSize / Width = 300
sizePolicy / Horizontal Stretch = 1
Basically the above setup specifies the minimum width of these two components, and that QTableWidget is the one that will change it’s width during form resize.
The buttons on the right side are placed in QVBoxLayout and it’s size is fixed.
Question:
While resizing the form QTreeWidget‘s width goes from minimum 150 up to unknown 256, and only then QTableWidget starts to grow, while I expect QTreeWidget to not grow in width at all, since QTableWidget is the one, that has Horizontal Stretch set to 1.
Please note, this has nothing to do with QSplitter, since the same happens when I place these two widgets in QHBoxLayout instead.
UPDATE:
Setting QTreeWidget maximumSize / Width to 150 (same as minimumSize / Width) to avoid resizing of this widget gives following:

QTreeWidget is fixed now to 150, but when the window is resized there is an empty gap between the two widgets. This gap grows up to 256-150=106, and then QTableWidget starts to expand.
Basically the result is similar, but this time area that was taken by QTreeWidget now is dedicated to this empty gap.
I’ve started to feel this might be a Qt bug.
Technical info:
- Ubuntu 10.04 (Lucid Lynx) x86_64
- GCC 4.4.3
- Qt 4.6.2
The size hint of 256 width is hard-coded into
QAbstractScrollArea. (Why? I have no idea.) Here is the method, from qabstractscrollarea.cpp:I’m not sure what’s going on with the
0macro … maybe someone started to implement a non-hardcoded width but didn’t finish, and this is for testing?Anyhow, you can work around it by subclassing
QTreeViewand implementing your own size hint, for example: