PDA

View Full Version : No scrollbars or stretching in QToolBox



zenzero-2001
7th August 2010, 17:35
Hello

This is a bit of newbie-ish question, even though I'm not a newbie. I have a QToolBox inside a QDockWidget. I have a custom widget "GeneralPage" that I add to the toolbox before adding that to the dockwidget. I have created "GeneralPage" using the designer, but everything else I have coded manually.

I have two problems. Problem 1, my various lineedits, comboboxes etc that I have on my page do not stretch as I would like, nor can I get them to be the initial size that I would like. Problem 2, shrinking the page so that it is too small to show the contents does not result in scrollbars appearing.

I have tried various layouts and spacers but nothing makes any difference. I've spent hours on this! I must be doing something fundamentally wrong. Perhaps I should code everything manually? Thanks.

zenzero-2001
8th August 2010, 14:51
Ok, I seem to have fixed the stretching problem and the lack of scrollbars.

I had previously tried placing everything in a VBoxLayout, but that didn't work. I compared what I was doing to the source code of another program which worked. The difference was that in the designer, the layout in the working example had its properties combined with the widget properties. Whereas, in mine the VBoxLayout had its own separate properties and its own entry in the object list.

So, I compared the UI files. In mine there was a second top level widget definition, not present in the working example:


<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<height>381</height>
</rect>
</property>
.
.
.
</widget>

I manually edited the UI file to remove this which left me with the layout at the top level (below the first widget definition):


<layout class="QVBoxLayout" name="verticalLayout">
.
.
.
</layout>

And the moral of the story is don't use the designer, code everything manually! :)