I'm trying to do something similar. I've got one fixed widget (top), and one non-fixed widget (bottom). I want the user to be able to use the splitter handle normally, but I don't want window resizes to add space to the fixed widget. Using setSizePolicy on both widgets didn't work for me, and neither did using setStretchFactor on either one or both widgets.
I ended up subclassing QSplitter so that I could implement a resizeEvent that would move the splitter after the splitter resized. This code assumes:
There are only two widgets.
The top [0] is resizeable, and the bottom [1] should not be.
Here is the resizeEvent that I wrote:
MySplitter::resizeEvent(QResizeEvent *event) {
/* The first resizeEvent is -1 for height and width, because it was
invisible before. */
if (event->oldSize().height() != -1) {
int diff;
QList<int> previousSizes = sizes();
QSplitter::resizeEvent(event);
QList<int> newSizes = sizes();
/* The bottom widget is the fixed one, so find out if that is to
grow or shrink. */
diff = newSizes[1] - previousSizes[1];
if (diff > 0) {
/* Keep the bottom from growing by giving the size to the top. */
newSizes[0] += diff;
newSizes[1] -= diff;
}
else {
/* Steal size from the top to keep it from shrinking. */
newSizes[0] -= diff;
newSizes[1] += diff;
}
setSizes(newSizes);
}
else
QSplitter::resizeEvent(event);
}