Qt-interest Archive, March 2002
Experiments in QtDesigner with boxLayouts
Message 1 in thread
Hello!
I'm currently trying out the QtDesigner of Qt 3.01 and it's layout capabilities. I wanted to design a resizable main window with this tool.
As I have some lines, each consisting of labels, lineedits and pushbuttons, I layouted each of these lines horizontally. If I now rescale the window, the hboxlayout box stays at the same size.
So I overwrote resizeEvent() for the main window/ dialog, trying to resize the hboxlayout. However, if I call setGeometry() for a QHBoxLayout type object, it doesn't rescale the layout frame itself but only the space in which all boxed elements are arranged.
This means: If I enlarge the window, the boxlayout's arrangement rect is enlarged, too, but parts of the controls are cropped, as the underlying qhbox control will not be enlarged, accordingly.
Unfortunately, I seem not to have the change to access the hbox object, rescaling it.
Has anybody a solution?
cheers,
Stephan
________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
Message 2 in thread
Try playing with the "Lay Out in a Grid" button in designer...I think you
will find it useful...
On Thursday 07 March 2002 05:07 am, Stephan Stapel wrote:
> Hello!
>
> I'm currently trying out the QtDesigner of Qt 3.01 and it's layout
> capabilities. I wanted to design a resizable main window with this tool. As
> I have some lines, each consisting of labels, lineedits and pushbuttons, I
> layouted each of these lines horizontally. If I now rescale the window, the
> hboxlayout box stays at the same size. So I overwrote resizeEvent() for the
> main window/ dialog, trying to resize the hboxlayout. However, if I call
> setGeometry() for a QHBoxLayout type object, it doesn't rescale the layout
> frame itself but only the space in which all boxed elements are arranged.
> This means: If I enlarge the window, the boxlayout's arrangement rect is
> enlarged, too, but parts of the controls are cropped, as the underlying
> qhbox control will not be enlarged, accordingly. Unfortunately, I seem not
> to have the change to access the hbox object, rescaling it. Has anybody a
> solution?
>
> cheers,
>
> Stephan
> ________________________________________________________________
> Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
> Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
Message 3 in thread
Hola~
I'm not sure I understand what you mean... The funny thing about layouts in
designer is that you need to apply a layout to the parent to manage the
children. Make sure you add a layout in the top level form widget.
>-- On Thu, Mar 07, 2002 at 11:07:40AM +0100, % wrote: Hello!
>
> I'm currently trying out the QtDesigner of Qt 3.01 and it's layout
> capabilities. I wanted to design a resizable main window with this tool. As
> I have some lines, each consisting of labels, lineedits and pushbuttons, I
> layouted each of these lines horizontally. If I now rescale the window, the
> hboxlayout box stays at the same size.
Try selecting the main window and adding a vertical layout.
If you are still stuck and your ui only has Qt widgets in it, either post it
or send it to me. I'll take a look.
After discovering the caveat about creating children layouts, I find I can do
nearly all layout tasks in designer interactively, which is a huge win over
having to recompile or implement stuff with QVBox and friends.
MO
> So I overwrote resizeEvent() for the
> main window/ dialog, trying to resize the hboxlayout. However, if I call
> setGeometry() for a QHBoxLayout type object, it doesn't rescale the layout
> frame itself but only the space in which all boxed elements are arranged.
> This means: If I enlarge the window, the boxlayout's arrangement rect is
> enlarged, too, but parts of the controls are cropped, as the underlying
> qhbox control will not be enlarged, accordingly. Unfortunately, I seem not
> to have the change to access the hbox object, rescaling it. Has anybody a
> solution?
>
> cheers,
>
> Stephan
> ________________________________________________________________
> Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
> Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
>
> --
> List archive and information: http://qt-interest.trolltech.com
--
[ signature omitted ]
Message 4 in thread
Stephan,
Your problem is related to a "feature" (read bug) in nested layouts.
Fortunately there are a number of workarounds. See the attached
correspondance with Trolltech.
> -----Original Message-----
> From: Stephan Stapel [mailto:stephan.stapel@web.de]
> Sent: March 7, 2002 5:08 AM
> To: qt-interest@trolltech.com
> Subject: Experiments in QtDesigner with boxLayouts
>
>
> Hello!
>
> I'm currently trying out the QtDesigner of Qt 3.01 and it's
> layout capabilities. I wanted to design a resizable main
> window with this tool.
> As I have some lines, each consisting of labels, lineedits
> and pushbuttons, I layouted each of these lines horizontally.
> If I now rescale the window, the hboxlayout box stays at the
> same size.
> So I overwrote resizeEvent() for the main window/ dialog,
> trying to resize the hboxlayout. However, if I call
> setGeometry() for a QHBoxLayout type object, it doesn't
> rescale the layout frame itself but only the space in which
> all boxed elements are arranged.
> This means: If I enlarge the window, the boxlayout's
> arrangement rect is enlarged, too, but parts of the controls
> are cropped, as the underlying qhbox control will not be
> enlarged, accordingly.
> Unfortunately, I seem not to have the change to access the
> hbox object, rescaling it.
> Has anybody a solution?
>
> cheers,
>
> Stephan
> ________________________________________________________________
> Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
> Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
>
> --
> List archive and information: http://qt-interest.trolltech.com
>
--- Begin Message ---
Dear Nigel,
> I have attached a little example.
> Qmake/nmake bug.exe, then run it. The top combobox has 3 modes which
control
> what will be shown. Select mode 1 and everything will be hidden except the
> arrow size selector. BUT do you see the BIG spacing between the mode
> combobox and the arrow size selector? Similarly, if you select mode2
> eveything except the mode combobox will be hidden, BUT again do you see
the
> big gap at the bottom of the combobox?
> Now, go into Designer and change the displayGroup GroupBox layoutSpacing
> property from 6 to 0 pixels. Now everything behaves as it should.
The problem is related to nested layouts. Even if you hide all the widgets
in a
sub-layout, the sub-layout itself will still take 0 pixels and will be
surrounded by a 6-pixel border.
* ComboBox
* 6 pixels
* 0-pixel-high sub-layout
* 6 pixels
* 0-pixel-high sub-layout
* 6 pixels
* etc.
Layouts, unlike widgets, don't have this concept of being hidden. I will
look at
it and see if I can change this without breaking binary compatibility for Qt
3.1, but I recommend that you try one of many work-arounds.
Work-around #1: Instead of using nested layouts, create a QFrame object and
layout the QLabels and QLineEdits and QSpinBoxes within it. You will need to
set
the "frameShape" property to NoFrame, and "layoutMargin" to 0. Then you can
hide
the QFrame objects, and the layout around them will adapt as you expect.
Work-around #2: Set the "layoutMargin" to 0, and add fake 6-pixel-high
widgets
to space out the widgets manually. Use for example QFrame with NoFrame.
Work-around #3: Use QWidgetStack to select between one of three pages.
Unfortunately QWidgetStack is not supported by Qt Designer in Qt 3.0 (it
will be
in Qt 3.1, to be released in a few months), so it's probably not a good
option.
Work-around #4: Use QTabDialog and design the different pages in Qt
Designer.
This will, in general, result in a dialog that is easier to use.
I'm sorry if all I have to provide is work-arounds, but Qt Designer and
layouts
are thought for the common case in mind. Dynamic dialogs will always require
some extra work, especially if done with Qt Designer, which has a very
static
view of things.
Have a nice day!
Jasmin
--- End Message ---