Qt:Документация 4.3.2/q3sqlpropertymap

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] Q3SqlPropertyMap Class Reference
[ Qt3Support module]

The Q3SqlPropertyMap class is used to map widgets to SQL fields. Далее...

 #include <Q3SqlPropertyMap>

This class is part of the Qt 3 support library. It is provided to keep old source code working. Мы настоятельно не рекомендуем использовать этот класс в новом коде. See Porting to Qt 4 for more information.

Note to Qt Desktop Light Edition users: This class is only available in the Qt Desktop Edition.

[править] Открытые функции

[править] Статические открытые члены


[править] Подробное описание

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

The SQL module uses Qt 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 QLineEdit can be used to edit text strings and other data types in Q3DataTables or Q3SqlForms. Several properties are defined in QLineEdit, but only the text property is used to insert and extract text from a QLineEdit. Both Q3DataTable and Q3SqlForm use the global Q3SqlPropertyMap 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 Q3DataTable or Q3SqlForm, you must install your own Q3SqlPropertyMap for that table or form. Пример:

 Q3SqlPropertyMap *myMap  = new Q3SqlPropertyMap();
 Q3SqlForm        *myForm = new Q3SqlForm(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 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(&amp;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 Q3SqlPropertyMap that is used by default. (Bear in mind that Q3SqlPropertyMap takes ownership of the new default map.)

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

See also Q3DataTable, Q3SqlForm, and Q3SqlEditorFactory.


[править] Описание функций-членов

[править]
Q3SqlPropertyMap::Q3SqlPropertyMap ()

Constructs a Q3SqlPropertyMap.

The default property mappings used by Qt widgets are:


Widgets Property
QCheckBox, QRadioButton checked
QComboBox, Q3ListBox currentItem
Q3DateEdit date
Q3DateTimeEdit QDateTimeEdit dateTime
QTextBrowser source
QAbstractButton, QDial, QLabel, QLineEdit, Q3MultiLineEdit, QPushButton, QTextEdit, text
Q3TimeEdit time
QLCDNumber, QScrollBar QSlider, QSpinBox value

[править]
Q3SqlPropertyMap::~Q3SqlPropertyMap () [virtual]

Destroys the Q3SqlPropertyMap.

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

[править]
Q3SqlPropertyMap * Q3SqlPropertyMap::defaultMap () [static]

Returns the application global Q3SqlPropertyMap.

[править]
void Q3SqlPropertyMap::insert ( const QString & classname, const QString & property )

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

[править]
void Q3SqlPropertyMap::installDefaultMap ( Q3SqlPropertyMap * map ) [static]

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

[править]
QVariant Q3SqlPropertyMap::property ( QWidget * widget )

Returns the mapped property of widget as a QVariant.

See also setProperty().

[править]
void Q3SqlPropertyMap::remove ( const QString & classname )

Removes classname from the map.

[править]
void Q3SqlPropertyMap::setProperty ( QWidget * widget, const QVariant & value ) [virtual]

Sets the property of widget to value.

See also property().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2