[solved] Issues with resizing widgets inside QHBoxLayout
-
wrote on 27 Jan 2014, 01:24 last edited by
I have a QHBoxLayout layout applied to a widget, and then I have many widgets added to it. These widgets have an exapnd button which, when clicked, it either expands the widget size or shrinks it. The purpose is to show more controls when expanded and fewer when shrinked. These widgets only resize horizontally.
When i try the widgets on their own (not added to the layout) they work perfectly, the widget window is expanded/shrinked as expected. Unfortunately, when I add this widget to the layout expanding the widget is unsuccessful; the layout will keep the initial (shirnked) size of the widget so the widget is actually expanding but visually it will be only partially visible. The problem is the layout is not considering the fact that the widget has changed size.-I searched the docs and I found I should set a QSizePolicy to my widget and in this set the horizontal and vertical policies; But in the official documentation QSizePolicy is nowhere to be found. I found "this page":http://qtdocs.narod.ru/4.1.0/doc/html/qsizepolicy.html which seems to be a "copy" of the old documentation from Qt 3, but I haven't been able to use it anyway.- found it right now, still unable to use it...
Can someone help me setting up the layout so it properly resizes when a widget inside changes size?
EDIT
to better understand what I mean please see the image example below:
!http://img.networkdigitale.com/di/TK4G/lyutrsz.png(image)!
(the scrollbar on the bottom is still to be implemented using a QScrollArea) -
wrote on 27 Jan 2014, 02:43 last edited by
Nevermind, It seems it was fixed with a simple coding trick. I was adding the widgets with
layout->addWidget(pWidget, 0, Qt::AlignCenter);
Instead, when I added the widget using the default stretch factor and center values it worked fine:
layout->addWidget(pWidget);
1/2