[Developers] Simple selection dialogs

Bert Bril Bert.Bril at opendtect.org
Mon Jan 15 11:31:21 CET 2007


Hi all,

There are a couple of really simple dialogs available to do - as you 
would expect - really simple things. Easy examples are the UIMSG() class 
  dialogs (errors, messages, decisions). In uiTools, there are a couple 
more that are simple combinations of a few services in uiBase.

The difference between the classes in uiBase and uiTools is, a.o., that 
uiBase classes use Qt directly - whereas uiTools (and all other ui... 
classes) can only use other ui... classes. In terms of dependencies: 
only the uiBase classes are compile-time dependent on Qt.

I would like to draw the attention to two uiTools classes that may come 
in handy in lots of situations. I've just re-worked the header file 
uiselsimple.h:

* A class for selecting a single string from a list: uiSelectFromList.

     uiSelectFromList::Setup listsetup( "Retrieve data format",
                                        availablefmts );
     listsetup.dlgtitle( "Select a format to retrieve" );
     uiSelectFromList dlg( this, listsetup );
     if ( dlg.go() )
     {
	const char* selectedfmt = dlg.text();
	// etc.
     }

* A class for asking a name, displaying names that are already 
established: uiGetObjectName.

     uiGetObjectName::Setup listsetup( "Save format", nms );
     listsetup.inptxt( "Name for format" )
              .deflt( ds_.fmtname_ )
              .dlgtitle( "Enter a name for the format" );
     uiGetObjectName dlg( this, listsetup );

Note again: the above are the interfaces as they are is in the current 
CVS repository - which will be the interface for version 3.0.


You can use these classes 'as-is', but it is also possible to add one or 
two fields before pop-up. For example, the above uiGetObjectName code 
can be extendended as follows:

     static const char* strs[] = { "In survey only",
                                   "In all surveys",
                                   "By me only" };
     uiGenInput* storesrcfld = new uiGenInput( &dlg, "Store for use",
                                          StringListInpSpec(strs) );
     storesrcfld->attach( alignedBelow, dlg.inpFld() );
     if ( dlg.go() )
     {
	const char* fmtnm = dlg.text();
	const int sourcesel = storesrcfld->getIntValue();
	// etc.
     }

There is nothing special here: this 'trick' can be done (with care) to 
any dialog.


/Bert

-- 
-- Bert Bril / OpendTect developer at dGB
-- Nijverheidstraat 11-2, 7511 JM Enschede, The Netherlands
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org
-- Tel: +31 534315155 , Fax: +31 534315104




More information about the Developers mailing list