qsplitter children sizes
-
i have two widgets and i need to place them inside a splitter.
this is what i have:
auto widget1 = new QWidget(this); auto widget2 = new QWidget(this); widget2->setFixedHeight(60); auto splitter = new QSplitter(Qt::Vertical, this); splitter->addWidget(widget1); splitter->addWidget(widget2); splitter->setChildrenCollapsible(false); splitter->setStretchFactor(0, 50); splitter->setStretchFactor(1, 0); splitter->setSizes(QList() << widget1->sizeHint().height() << widget2->height()); splitter->show();
the problem is that i need the second widget small and the first one to be its normal size.
when i don't add the second widget, first one has the ideal size for me.
when i add the second one, the first one becomes bigger than the ideal size.above is what i've tried to apply to fix it but no luck. any idea?
-
Hi
Do you mean one normal height and one less than full height ?
it seems not to really like it. (using max height)
-
Hi
Do you mean one normal height and one less than full height ?
it seems not to really like it. (using max height)
@mrjj
no, initially the two widgets occupied the same height, i.e. (height/2)
so i made the second one small (by setting fixed size)
and now the first widget occupies the place that was "released" by second widget -
Hi
From small tests i just did, it dont seems like QSplitter allows/supports
different heights for the widgets. will it seems to work for a moment using
fixed/setmax methods, it behaves oddly when refreshed. -
Hi
You could put 2 grid layouts in the splitter. seems to work pretty ok
-
@mrjj
okay i need this, only widgets are vertically laid out -
how do i add a layout to splitter?
-
how do i add a layout to splitter?
@user4592357 said in qsplitter children sizes:
how do i add a layout to splitter?
You don't. You create two layouts like @mrjj shown, then select both and then click on "Lay Out horizontally in Splitter.
-
@user4592357 said in qsplitter children sizes:
how do i add a layout to splitter?
You don't. You create two layouts like @mrjj shown, then select both and then click on "Lay Out horizontally in Splitter.
@jsulm
i'm not using designer -
@jsulm
i'm not using designer@user4592357 Then add two widgets and in each widget add a layout
-
@user4592357 Then add two widgets and in each widget add a layout
@jsulm
what about splitter then? -
Hi
You could just use designer
and then take the c++ code.
Code is in setupUI() -
@mrjj
i tried to do that but i need to lay them out vertically which gives the same result as writing the code -
@mrjj
i tried to do that but i need to lay them out vertically which gives the same result as writing the code@user4592357
Hi
Im not sure what goes wrong. the concept seems to work.
do u have mutiple widgets pr side in splitter of what is difference to the mini test? -
@user4592357
Hi
Im not sure what goes wrong. the concept seems to work.
do u have mutiple widgets pr side in splitter of what is difference to the mini test?@mrjj
i create one tall widget at top and one short widget at bottom. then i select lay out vertically in splitter.
and both get smaller size:
after laying out:
-
@mrjj
i create one tall widget at top and one short widget at bottom. then i select lay out vertically in splitter.
and both get smaller size:
after laying out:
@user4592357
Hi
yes, the Splitter adjust a bit to the sizehints of the widgets if no min/max is set.
So the issue is that they become smaller when inserted into splitter ? -
@user4592357
Hi
yes, the Splitter adjust a bit to the sizehints of the widgets if no min/max is set.
So the issue is that they become smaller when inserted into splitter ?@mrjj
now yes,
with code the only first one became taller -
@mrjj
now yes,
with code the only first one became taller@user4592357
but do you set min/max on them or how do you control size ? -
@user4592357
but do you set min/max on them or how do you control size ?@mrjj
i set min and max sizes to the same value and got this after puttting in splitter:
widgets got narrower.
-
@mrjj
i set min and max sizes to the same value and got this after puttting in splitter:
widgets got narrower.
@user4592357
you set the min/max on the widgets?
it works here.