Q3SqlForm Class ReferenceThe Q3SqlForm class creates and manages data entry forms tied to SQL databases. Далее... #include <Q3SqlForm> Данный класс является частью библиотеки поддержки Qt 3. Он предоставлен для поддержки ранее написанного кода. Мы настоятельно не рекомендуем использовать этот класс в новом коде. Для получения дополнительной информации смотрите Портирование на Qt 4. Унаследован от: QObject. Открытые функции
Открытые слоты
Защищенные функции
Дополнительные унаследованные члены
Подробное описаниеThe Q3SqlForm class creates and manages data entry forms tied to SQL databases. Typical use of a Q3SqlForm consists of the following steps:
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 () constReturns the number of widgets in the form. QWidget * Q3SqlForm::fieldToWidget ( QSqlField * field ) constReturns 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 ) constReturns the i-th widget in the form. Useful for traversing the widgets in the form. QSqlField * Q3SqlForm::widgetToField ( QWidget * widget ) constReturns 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. |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |