Resize widgets in a splitter
-
wrote on 4 Apr 2019, 10:17 last edited by
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 ?
-
wrote on 7 Apr 2019, 10:22 last edited by
Exactly :)
-
wrote on 7 Apr 2019, 14:59 last edited by
Hi! You can set the
setMinimumWidth
to the widget andsetHorizontalStretch
(https://doc.qt.io/qt-5/qsizepolicy.html#setHorizontalStretch) to theQSizePolicy
. -
wrote on 7 Apr 2019, 15:40 last edited by NoumanYosuf 4 Jul 2019, 15:41
@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. -
wrote on 10 Apr 2019, 10:21 last edited by
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
1/6