Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

Q3SqlPropertyMap Class

TheQ3SqlPropertyMap class is used to map widgets to SQL fields.More...

Header:#include <Q3SqlPropertyMap>

Public Functions

Q3SqlPropertyMap()
virtual~Q3SqlPropertyMap()
voidinsert(const QString & classname, const QString & property)
QVariantproperty(QWidget * widget)
voidremove(const QString & classname)
virtual voidsetProperty(QWidget * widget, const QVariant & value)

Static Public Members

Q3SqlPropertyMap *defaultMap()
voidinstallDefaultMap(Q3SqlPropertyMap * map)

Detailed Description

TheQ3SqlPropertyMap class is used to map widgets to SQL fields.

The SQL module uses Qtobject 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, aQLineEdit can be used to edit text strings and other data types in Q3DataTables or Q3SqlForms. Several properties are defined inQLineEdit, but only thetext property is used to insert and extract text from aQLineEdit. BothQ3DataTable andQ3SqlForm use the globalQ3SqlPropertyMap 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 yourQ3DataTable orQ3SqlForm, you must install your ownQ3SqlPropertyMap for that table or form. Example:

Q3SqlPropertyMap*myMap=newQ3SqlPropertyMap();Q3SqlForm*myForm=newQ3SqlForm(this);MyEditor myEditor(this);// Set the Q3SqlForm's record buffer to the update buffer of// a pre-existing Q3SqlCursor called 'cur'.myForm->setRecord(cur->primeUpdate());// Install the customized mapmyMap->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 fieldmyForm->readFields();...// Let the user edit the form...// Update the database fields with the values in the formmyForm->writeFields();...

You can also replace the globalQ3SqlPropertyMap that is used by default. (Bear in mind thatQ3SqlPropertyMap takes ownership of the new default map.)

Q3SqlPropertyMap*myMap=newQ3SqlPropertyMap;myMap->insert("MyEditor","content");Q3SqlPropertyMap::installDefaultMap(myMap);...

See alsoQ3DataTable,Q3SqlForm, andQ3SqlEditorFactory.

Member Function Documentation

Q3SqlPropertyMap::Q3SqlPropertyMap()

Constructs aQ3SqlPropertyMap.

The default property mappings used by Qt widgets are:

[virtual]Q3SqlPropertyMap::~Q3SqlPropertyMap()

Destroys theQ3SqlPropertyMap.

Note that if theQ3SqlPropertyMap is installed with installPropertyMap() the object it was installed into, e.g. theQ3SqlForm, takes ownership and will delete theQ3SqlPropertyMap when necessary.

[static]Q3SqlPropertyMap * Q3SqlPropertyMap::defaultMap()

Returns the application globalQ3SqlPropertyMap.

void Q3SqlPropertyMap::insert(constQString & classname, constQString & property)

Insert a new classname/property pair, which is used for custom SQL field editors. Theremust be aQ_PROPERTY() clause in theclassname class declaration for theproperty.

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

Replaces the global default property map withmap. AllQ3DataTable andQ3SqlForm instantiations will use this new map for inserting and extracting values to and from editors.Q3SqlPropertyMap takes ownership ofmap, and destroys it when it is no longer needed.

QVariant Q3SqlPropertyMap::property(QWidget * widget)

Returns the mapped property ofwidget as aQVariant.

See alsosetProperty().

void Q3SqlPropertyMap::remove(constQString & classname)

Removesclassname from the map.

[virtual]void Q3SqlPropertyMap::setProperty(QWidget * widget, constQVariant & value)

Sets the property ofwidget tovalue.

See alsoproperty().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp