Qt:Документация 4.3.2/q3sqlform
Материал из Wiki.crossplatform.ru
(Новая: {{Qt4.3.2_header}} =Q3SqlForm Class Reference<br /><sup><sup> [ Qt3Support module]</sup></sup>= The Q3SqlForm class creates and manag...)
Текущая версия на 13:26, 29 января 2009
Внимание: Актуальная версия перевода документации находится здесь |
__NOTOC__
Главная · Все классы · Основные классы · Классы по группам · Модули · Функции |
[править] Q3SqlForm Class Reference
[ Qt3Support module]
The Q3SqlForm class creates and manages data entry forms tied to SQL databases. Далее...
#include <Q3SqlForm>
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.
Inherits QObject.
[править] Открытые функции
- Q3SqlForm ( QObject * parent = 0 )
- ~Q3SqlForm ()
- int count () const
- QWidget * fieldToWidget ( QSqlField * field ) const
- virtual void insert ( QWidget * widget, const QString & field )
- void installPropertyMap ( Q3SqlPropertyMap * pmap )
- virtual void remove ( const QString & field )
- virtual void setRecord ( QSqlRecord * buf )
- QWidget * widget ( int i ) const
- QSqlField * widgetToField ( QWidget * widget ) const
- 29 открытых функций, унаследованных от QObject
[править] Открытые слоты
- virtual void clear ()
- virtual void clearValues ()
- virtual void readField ( QWidget * widget )
- virtual void readFields ()
- virtual void writeField ( QWidget * widget )
- virtual void writeFields ()
- 1 открытый слот, унаследованный от QObject
[править] Защищенные функции
- virtual void insert ( QWidget * widget, QSqlField * field )
- virtual void remove ( QWidget * widget )
- 7 защищенных функций, унаследованных от QObject
[править] Дополнительные унаследованные члены
- 1 свойство, унаследованное от QObject
- 1 сигнал, унаследованный от QObject
- 5 статических открытых членов, унаследованных от QObject
[править] Подробное описание
The Q3SqlForm class creates and manages data entry forms tied to SQL databases.
Typical use of a Q3SqlForm consists of the following steps:
- Create the widgets you want to appear in the form.
- Create a cursor and navigate to the record to be edited.
- Create the Q3SqlForm.
- Set the form's record buffer to the cursor's update buffer.
- Insert each widget and the field it is to edit into the form.
- Use readFields() to update the editor widgets with values from the database's fields.
- Display the form and let the user edit values etc.
- Use writeFields() to update the database's field values with the values in the editor widgets.
Note that a Q3SqlForm does not access the database directly, but most often via QSqlFields which are part of a Q3SqlCursor. A Q3SqlCursor::insert(), Q3SqlCursor::update() or Q3SqlCursor::del() call is needed to actually write values to the database.
Some sample code to initialize a form successfully:
QLineEdit myEditor(this); Q3SqlForm myForm(this); Q3SqlCursor myCursor("mytable"); // Execute a query to make the cursor valid myCursor.select(); // Move the cursor to a valid record (the first record) myCursor.next(); // Set the form's record pointer to the cursor's edit buffer (which // contains the current record's values) myForm.setRecord(myCursor.primeUpdate()); // Insert a field into the form that uses myEditor to edit the // field 'somefield' in 'mytable' 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 myForm.writeFields(); // Update the cursor's edit buffer from the form myCursor.update(); // Update the database from the cursor's buffer
If you want to use custom editors for displaying and editing data fields, you must install a custom Q3SqlPropertyMap. The form uses this object to get or set the value of a widget.
See also installPropertyMap() and Q3SqlPropertyMap.
[править] Описание функций-членов
[править] Q3SqlForm::Q3SqlForm ( QObject * parent = 0 )
Constructs a Q3SqlForm with parent parent.
[править] Q3SqlForm::~Q3SqlForm ()
Удаляет объект и очищает любые выделенные ресурсы.
[править] void Q3SqlForm::clear () [virtual slot]
Removes every widget, and the fields they're mapped to, from the form.
[править] void Q3SqlForm::clearValues () [virtual slot]
Clears the values in all the widgets, and the fields they are mapped to, in the form, and sets them to NULL.
[править] int Q3SqlForm::count () const
Returns the number of widgets in the form.
[править] QWidget * Q3SqlForm::fieldToWidget ( QSqlField * field ) const
Returns the widget that field field is mapped to.
[править] void Q3SqlForm::insert ( QWidget * widget, const QString & field ) [virtual]
Inserts a widget, and the name of the field it is to be mapped to, into the form. To actually associate inserted widgets with an edit buffer, use setRecord().
See also setRecord().
[править] void Q3SqlForm::insert ( QWidget * widget, QSqlField * field ) [virtual protected]
Эта перегруженная функция предоставлена для удобства.
Inserts a widget, and the field it is to be mapped to, into the form.
[править] void Q3SqlForm::installPropertyMap ( Q3SqlPropertyMap * pmap )
Installs a custom Q3SqlPropertyMap. This is useful if you plan to create your own custom editor widgets.
Q3SqlForm takes ownership of pmap, so pmap is deleted when Q3SqlForm goes out of scope.
See also Q3DataTable::installEditorFactory().
[править] void Q3SqlForm::readField ( QWidget * widget ) [virtual slot]
Updates the widget widget with the value from the SQL field it is mapped to. Nothing happens if no SQL field is mapped to the widget.
[править] void Q3SqlForm::readFields () [virtual slot]
Updates the widgets in the form with current values from the SQL fields they are mapped to.
[править] void Q3SqlForm::remove ( QWidget * widget ) [virtual protected]
Removes a widget, and hence the field it's mapped to, from the form.
[править] void Q3SqlForm::remove ( const QString & field ) [virtual]
Эта перегруженная функция предоставлена для удобства.
Removes field from the form.
[править] void Q3SqlForm::setRecord ( QSqlRecord * buf ) [virtual]
Sets buf as the record buffer for the form. To force the display of the data from buf, use readFields().
See also readFields() and writeFields().
[править] QWidget * Q3SqlForm::widget ( int i ) const
Returns the i-th widget in the form. Useful for traversing the widgets in the form.
[править] QSqlField * Q3SqlForm::widgetToField ( QWidget * widget ) const
Returns the SQL field that widget widget is mapped to.
[править] void Q3SqlForm::writeField ( QWidget * widget ) [virtual slot]
Updates the SQL field with the value from the widget it is mapped to. Nothing happens if no SQL field is mapped to the widget.
[править] void Q3SqlForm::writeFields () [virtual slot]
Updates the SQL fields with values from the widgets they are mapped to. To actually update the database with the contents of the record buffer, use Q3SqlCursor::insert(), Q3SqlCursor::update() or Q3SqlCursor::del() as appropriate.
Copyright © 2007 Trolltech | Trademarks | Qt 4.3.2
|