The QSqlPropertyMap class is used to map widgets to SQL fields.
.PP
The SQL module uses Qt object properties to insert and extract values from editor widgets.
.PP
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.
.PP
For example, a QLineEdit can be used to edit text strings and other data types in QDataTables or QSqlForms. Several properties are defined in QLineEdit, but only the \fItext\fR property is used to insert and extract text from a QLineEdit. Both QDataTable and QSqlForm use the global QSqlPropertyMap 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.
.PP
If you want to use custom editors with your QDataTable or QSqlForm, you must install your own QSqlPropertyMap for that table or form. Example:
.PP
.nf
.br
QSqlPropertyMap *myMap = new QSqlPropertyMap();
.br
QSqlForm *myForm = new QSqlForm( this );
.br
MyEditor myEditor( this );
.br
.br
// Set the QSqlForm's record buffer to the update buffer of
.br
// a pre-existing QSqlCursor called 'cur'.
.br
myForm->setRecord( cur->primeUpdate() );
.br
.br
// Install the customized map
.br
myMap->insert( "MyEditor", "content" );
.br
myForm->installPropertyMap( myMap ); // myForm now owns myMap
.br
...
.br
// Insert a field into the form that uses a myEditor to edit the
.br
// field 'somefield'
.br
myForm->insert( &myEditor, "somefield" );
.br
.br
// Update myEditor with the value from the mapped database field
.br
myForm->readFields();
.br
...
.br
// Let the user edit the form
.br
...
.br
// Update the database fields with the values in the form
.br
myForm->writeFields();
.br
...
.br
.fi
.PP
You can also replace the global QSqlPropertyMap that is used by default. (Bear in mind that QSqlPropertyMap takes ownership of the new default map.)
.PP
.nf
.br
QSqlPropertyMap *myMap = new QSqlPropertyMap;
.br
.br
myMap->insert( "MyEditor", "content" );
.br
QSqlPropertyMap::installDefaultMap( myMap );
.br
...
.br
.fi
.PP
See also QDataTable, QSqlForm, QSqlEditorFactory, and Database Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QSqlPropertyMap::QSqlPropertyMap ()"
Constructs a QSqlPropertyMap.
.PP
The default property mappings used by Qt widgets are: <center>.nf
.TS
l - l. Widgets Property QCheckBox, QRadioButton checked QComboBox, QListBox currentItem QDateEdit date QDateTimeEdit dateTime QTextBrowser source QButton, QDial, QLabel, QLineEdit, QMultiLineEdit, QPushButton, QTextEdit, text QTimeEdit time QLCDNumber, QScrollBar QSlider, QSpinBox
Note that if the QSqlPropertyMap is installed with installPropertyMap() the object it was installed into, e.g. the QSqlForm, takes ownership and will delete the QSqlPropertyMap when necessary.
Insert a new classname/property pair, which is used for custom SQL field editors. There \fImust\fR be a \fCQ_PROPERTY\fR clause in the \fIclassname\fR class declaration for the \fIproperty\fR.
Replaces the global default property map with \fImap\fR. All QDataTable and QSqlForm instantiations will use this new map for inserting and extracting values to and from editors. \fIQSqlPropertyMap takes ownership of \a map, and destroys it when it is no longer needed.\fR