Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQSqlPropertyMap class is used to map widgets to SQL fields. More...
#include <ntqsqlpropertymap.h>
The SQL module uses TQt object properties to insert and extract values from editor widgets.
This class is used to map editors to SQL fields. This works by associating SQL editor class names to the properties used to insert and extract values to/from the editor.
For example, a TQLineEdit can be used to edit text strings and other data types in TQDataTables or TQSqlForms. Several properties are defined in TQLineEdit, but only the text property is used to insert and extract text from a TQLineEdit. Both TQDataTable and TQSqlForm use the global TQSqlPropertyMap for inserting and extracting values to and from an editor widget. The global property map defines several common widgets and properties that are suitable for many applications. You can add and remove widget properties to suit your specific needs.
If you want to use custom editors with your TQDataTable or TQSqlForm, you must install your own TQSqlPropertyMap for that table or form. Example:
TQSqlPropertyMap *myMap = new TQSqlPropertyMap(); TQSqlForm *myForm = new TQSqlForm( this ); MyEditor myEditor( this ); // Set the TQSqlForm's record buffer to the update buffer of // a pre-existing TQSqlCursor called 'cur'. myForm->setRecord( cur->primeUpdate() ); // Install the customized map myMap->insert( "MyEditor", "content" ); myForm->installPropertyMap( myMap ); // myForm now owns myMap ... // Insert a field into the form that uses a myEditor to edit the // field 'somefield' myForm->insert( &myEditor, "somefield" ); // Update myEditor with the value from the mapped database field myForm->readFields(); ... // Let the user edit the form ... // Update the database fields with the values in the form myForm->writeFields(); ...
You can also replace the global TQSqlPropertyMap that is used by default. (Bear in mind that TQSqlPropertyMap takes ownership of the new default map.)
TQSqlPropertyMap *myMap = new TQSqlPropertyMap; myMap->insert( "MyEditor", "content" ); TQSqlPropertyMap::installDefaultMap( myMap ); ...
See also TQDataTable, TQSqlForm, TQSqlEditorFactory, and Database Classes.
Constructs a TQSqlPropertyMap.
The default property mappings used by TQt widgets are:
Widgets | Property |
---|---|
TQCheckBox, TQRadioButton | checked |
TQComboBox, TQListBox | currentItem |
TQDateEdit | date |
TQDateTimeEdit | dateTime |
TQTextBrowser | source |
TQButton, TQDial, TQLabel, TQLineEdit, TQMultiLineEdit, TQPushButton, TQTextEdit, | text |
TQTimeEdit | time |
TQLCDNumber, TQScrollBar TQSlider, TQSpinBox | value |
Note that if the TQSqlPropertyMap is installed with installPropertyMap() the object it was installed into, e.g. the TQSqlForm, takes ownership and will delete the TQSqlPropertyMap when necessary.
Example: sql/overview/custom1/main.cpp.
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|