Resize widgets in a splitter
-
Hi, I have a horizontal splitter with 2 widgets.
The widget on the right is a table with an unknown number of columns.
I would like to grammatically adjust the splitter position so that the table on the right is fully in view.
I tried setting the widget on the right sizePolicy to preferred, but it doesn't to the trick.
Thx in advance -
Hi,
do you mean that you want that table view to always be fully visible ?
-
Hi! You can set the
setMinimumWidth
to the widget andsetHorizontalStretch
(https://doc.qt.io/qt-5/qsizepolicy.html#setHorizontalStretch) to theQSizePolicy
. -
@nzur so you want your table widget to get adjusted automatically when splitter is moved ? please correct me if i have misunderstood your question.
Ideally, resized event is called of the added widgets in qsplitter when splitter is resized. And if the added widgets resize fine individually (when not added to splitter), it should work well.
Or if they don't and you want to handle resizing in the qsplitter, you can over ride resize event of qsplitter and then resize particular widget. -
I just wanted to locate the splitter so that all the table columns are visible.
I tried using QSplitter::setSizes() with the table width but it wasn't updated right after creation.
I solved it by overriding the table's resizeEvent() and emitting a signal to the parent widget