Need more Info on QSplitter & how it is replacing QLayouts.



  • I've seen that QSplitter can be an alternate for QLayouts but i din't find more information on how splitter deals with laying out widgets.
    I'm aware of it's advantages like being able to resize child widgets inside a splitter but i want to know more details about how it replaces layouts like,

    • Does it respect sizepolicies & sizehints as layouts
    • Does it have a default sizepolicy as a layout (in which case it won't respect child widget sizepolicies i think)

    Also, i'm interested in knowing how splitter handles child widgets which already have layouts. Does it recieve QEvent::LayoutRequest & passes it on to child widgets.?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QSplitter doesn't replace a layout. You just have widgets side by side or on top of each other but thats all.

    What is your use case ?



  • Thanks for responding @SGaist ,

    Can you elaborate on what you meant by "QSplitter doesn't replace a layout. You just have widgets side by side or on top of each other but thats all".
    I know that when i use a splitter inside a widget, i can use it as a layout. Do you mean i still need a layout (even though i have a splitter).?

    My use case is that i have some widgets with layouts installed on them. But i want to include splitters on top of that widget so that i can add more widgets to a single splitter & also have nested splitters inside a splitter.


  • Lifetime Qt Champion

    Layouts are used to setup how the elements of your complex widgets are positioned.

    A splitter is a "container", it won't do any special handling of what can be found inside the widgets you put in it.


Log in to reply