PDA

View Full Version : qsplitter children resizing help



mcarter
1st February 2013, 00:07
I have a custom widget (panel) that consists of a "titlebar" and another widget, eg scrollarea or a "canvas" widget for drawing. I have added multiple instances of these to a QSplitter widget. This works fine . . . the user can re-proportion the widgets to the sizes they like.

I have a feature request that I am trying to figure out. The user wants to be able to double-click on the titlebar and have the panel shrink to just the titlebar itself and then resize back when the action is performed again. I have implemented the double-click and I call hide/show on the internal widget. This all seems to work fine . . . except . . . when I shrink down to the titlebar itself, I cannot seem to get the occupied space of the child to shrink to just the titlebar. Only the titlebar is displayed when the other widget is hidden, but it is centered in the previous childs height. If I grab the handle with the mouse, I can manually shrink the child widget to the size of just the titlebar. I am also interested in finding a way so that the panel with just a titlebar cannot be resized with the splitter handle. I have tried different combinations of QSizePolicy on the panel widget to get the needed effect, but to no avail.

For right now, I have two panels in the qsplitter. What I am looking for is a way to shrink one of the panels to the size of the titlebar and have the other panel take the remaining space. Also, if both are double-clicked, I would like to see the whole main window be resized to the smaller size, and then resized as they are shown again.

Is it doable within the normal qsplitter implementation, or will I need to subclass QSplitter to get this additional functionality.

Santosh Reddy
1st February 2013, 11:46
I don't clearly understand your pproblem, could you show us a screenshot?

mcarter
1st February 2013, 15:57
Yeah, sometimes I ramble and do not quite get across my point . . .
So i created a sample program (not sure how to attach tgz file)
There are 3 panels (0,1,2) in use; the bottom two are in a QSplitter.

So here are 3 snapshots,

8667 8668 8669

1) normal startup
2) double clicked on titlebar of "Panel 1" with the unwanted effect
3) manually resizing window to show wanted effect

Santosh Reddy
1st February 2013, 17:30
May be you can try connecting the a signal to this slot

void QSplitter::moveSplitter ( int pos, int index ) [protected]

This signal should be emitted when the panel widget are hidden. When the panel widgets are visible, splitter should readjsut iteself by expanding

mcarter
1st February 2013, 23:04
moveSplitter is not a slot in QSplitter . . . also it is a protected method

Santosh Reddy
2nd February 2013, 06:20
Hmm... then you may need to have custom QSplitter