[Developers] Splitting your dialog
Nanne Hemstra
nanne at opendtect.org
Mon Oct 29 08:20:28 CET 2007
Hi all,
When you develop a dialog with a lot of fields it's always a good idea
to use the uiGroup class. All objects (or ui-fields) which kind of
belong to each other should be put into one group. It has multiple
advantages, first of all the layout becomes better, but also your code
is much cleaner and easier to understand.
When resizing the dialog you often want to be able to resize these
groups separately. In these situations the uiSplitter class can be used.
It gives you a nice handle between the groups to control their size. The
uiSplitter is build on top of Qt's QSplitter, but we implemented only a
few functions. Please look in $WORK/include/uiBase/ for the uisplitter.h
header file.
The constructor has three arguments, its parent (most often 'this'
pointer), a name, and the orientation or layout of the groups ('true'
for horizontally, 'false' for vertically). Then with addGroup you add
the groups which should be split from each other . When adding 2 groups
you get one handle, when adding 3 groups two handles, etc.
Here's an example of how you could write your code in a dialog's
constructor:
uiGroup* leftgrp = new uiGroup( this, "Left group" );
// add fields to leftgrp
uiGroup* rightgrp = new uiGroup( this, "Right group" );
// add fields to rightgrp
uiSplitter* splitter = new uiSplitter( this, "My Splitter", true );
splitter->addGroup( leftgrp );
splitter->addGroup( rightgrp );
Good luck.
Regards,
Nanne
--
- Nanne Hemstra
- OpendTect developer
-
- dGB India
- 304, Gateway Plaza
- Hiranandani Gardens, Powai
- Mumbai - 400 076, India
- Phone: +91 22 25704984 , Fax: +91 22 25704977
- Mobile: +91 9833452542
- http://www.dgb-group.com , http://www.opendtect.org
More information about the Developers
mailing list