Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQSqlPropertyMap Class Reference
[sql module]

The TQSqlPropertyMap class is used to map widgets to SQL fields. More...

#include <ntqsqlpropertymap.h>

List of all member functions.

Public Members

Static Public Members


Detailed Description

The TQSqlPropertyMap class is used to map widgets to SQL fields.

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.


Member Function Documentation

TQSqlPropertyMap::TQSqlPropertyMap ()

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

TQSqlPropertyMap::~TQSqlPropertyMap () [virtual]

Destroys the TQSqlPropertyMap.

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.

TQSqlPropertyMap * TQSqlPropertyMap::defaultMap () [static]

Returns the application global TQSqlPropertyMap.

void TQSqlPropertyMap::insert ( const TQString & classname, const TQString & property )

Insert a new classname/property pair, which is used for custom SQL field editors. There must be a TQ_PROPERTY clause in the classname class declaration for the property.

Example: sql/overview/custom1/main.cpp.

void TQSqlPropertyMap::installDefaultMap ( TQSqlPropertyMap * map ) [static]

Replaces the global default property map with map. All TQDataTable and TQSqlForm instantiations will use this new map for inserting and extracting values to and from editors. TQSqlPropertyMap takes ownership of \a map, and destroys it when it is no longer needed.

TQVariant TQSqlPropertyMap::property ( TQWidget * widget )

Returns the mapped property of widget as a TQVariant.

void TQSqlPropertyMap::remove ( const TQString & classname )

Removes classname from the map.

void TQSqlPropertyMap::setProperty ( TQWidget * widget, const TQVariant & value ) [virtual]

Sets the property of widget to value.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8