Eneboo - Documentación para desarrolladores
Slots públicos | Métodos públicos | Métodos protegidos
Referencia de la Clase QSqlForm

The QSqlForm class creates and manages data entry forms tied to SQL databases. Más...

#include <qsqlform.h>

Diagrama de herencias de QSqlForm
QObject QObject Qt Qt Qt Qt

Lista de todos los miembros.

Slots públicos

virtual void readField (QWidget *widget)
virtual void writeField (QWidget *widget)
virtual void readFields ()
virtual void writeFields ()
virtual void clear ()
virtual void clearValues (bool nullify=FALSE)
virtual void readField (QWidget *widget)
virtual void writeField (QWidget *widget)
virtual void readFields ()
virtual void writeFields ()
virtual void clear ()
virtual void clearValues (bool nullify=FALSE)

Métodos públicos

 QSqlForm (QObject *parent=0, const char *name=0)
 ~QSqlForm ()
virtual void insert (QWidget *widget, const QString &field)
virtual void remove (const QString &field)
uint count () const
QWidgetwidget (uint i) const
QSqlFieldwidgetToField (QWidget *widget) const
QWidgetfieldToWidget (QSqlField *field) const
void installPropertyMap (QSqlPropertyMap *map)
virtual void setRecord (QSqlRecord *buf)
 QSqlForm (QObject *parent=0, const char *name=0)
 ~QSqlForm ()
virtual void insert (QWidget *widget, const QString &field)
virtual void remove (const QString &field)
uint count () const
QWidgetwidget (uint i) const
QSqlFieldwidgetToField (QWidget *widget) const
QWidgetfieldToWidget (QSqlField *field) const
void installPropertyMap (QSqlPropertyMap *map)
virtual void setRecord (QSqlRecord *buf)

Métodos protegidos

virtual void insert (QWidget *widget, QSqlField *field)
virtual void remove (QWidget *widget)
void clearMap ()
virtual void insert (QWidget *widget, QSqlField *field)
virtual void remove (QWidget *widget)
void clearMap ()

Descripción detallada

The QSqlForm class creates and manages data entry forms tied to SQL databases.

sql

Typical use of a QSqlForm 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 QSqlForm. 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 QSqlForm does not access the database directly, but most often via QSqlFields which are part of a QSqlCursor. A QSqlCursor::insert(), QSqlCursor::update() or QSqlCursor::del() call is needed to actually write values to the database.

Some sample code to initialize a form successfully:

    QLineEdit  myEditor( this );
    QSqlForm   myForm( this );
    QSqlCursor 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 QSqlPropertyMap. The form uses this object to get or set the value of a widget.

Note that Qt Designer provides a visual means of creating data-aware forms.

Ver también:
installPropertyMap(), QSqlPropertyMap

Documentación del constructor y destructor

QSqlForm::QSqlForm ( QObject parent = 0,
const char *  name = 0 
)

Constructs a QSqlForm with parent parent and called name.

QSqlForm::~QSqlForm ( )

Destroys the object and frees any allocated resources.

QSqlForm::QSqlForm ( QObject parent = 0,
const char *  name = 0 
)
QSqlForm::~QSqlForm ( )

Documentación de las funciones miembro

void QSqlForm::clear ( void  ) [virtual, slot]

Removes every widget, and the fields they're mapped to, from the form.

virtual void QSqlForm::clear ( ) [virtual, slot]
void QSqlForm::clearMap ( ) [protected]
void QSqlForm::clearMap ( ) [protected]
void QSqlForm::clearValues ( bool  nullify = FALSE) [virtual, slot]

Clears the values in all the widgets, and the fields they are mapped to, in the form. If nullify is TRUE (the default is FALSE), each field is also set to NULL.

virtual void QSqlForm::clearValues ( bool  nullify = FALSE) [virtual, slot]
uint QSqlForm::count ( ) const
uint QSqlForm::count ( ) const

Returns the number of widgets in the form.

QWidget* QSqlForm::fieldToWidget ( QSqlField field) const
QWidget * QSqlForm::fieldToWidget ( QSqlField field) const

Returns the widget that field field is mapped to.

virtual void QSqlForm::insert ( QWidget widget,
const QString field 
) [virtual]
virtual void QSqlForm::insert ( QWidget widget,
QSqlField field 
) [protected, virtual]
void QSqlForm::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().

Ver también:
setRecord()
void QSqlForm::insert ( QWidget widget,
QSqlField field 
) [protected, virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts a widget, and the field it is to be mapped to, into the form.

void QSqlForm::installPropertyMap ( QSqlPropertyMap map)
void QSqlForm::installPropertyMap ( QSqlPropertyMap pmap)

Installs a custom QSqlPropertyMap. This is useful if you plan to create your own custom editor widgets.

QSqlForm takes ownership of pmap, so pmap is deleted when QSqlForm goes out of scope.

Ver también:
QDataTable::installEditorFactory()
void QSqlForm::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.

virtual void QSqlForm::readField ( QWidget widget) [virtual, slot]
void QSqlForm::readFields ( ) [virtual, slot]

Updates the widgets in the form with current values from the SQL fields they are mapped to.

virtual void QSqlForm::readFields ( ) [virtual, slot]
void QSqlForm::remove ( const QString field) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Removes field from the form.

virtual void QSqlForm::remove ( QWidget widget) [protected, virtual]
virtual void QSqlForm::remove ( const QString field) [virtual]
void QSqlForm::remove ( QWidget widget) [protected, virtual]

Removes a widget, and hence the field it's mapped to, from the form.

virtual void QSqlForm::setRecord ( QSqlRecord buf) [virtual]
void QSqlForm::setRecord ( QSqlRecord buf) [virtual]

Sets buf as the record buffer for the form. To force the display of the data from buf, use readFields().

Ver también:
readFields() writeFields()
QWidget * QSqlForm::widget ( uint  i) const

Returns the {i}-th widget in the form. Useful for traversing the widgets in the form.

QWidget* QSqlForm::widget ( uint  i) const
QSqlField * QSqlForm::widgetToField ( QWidget widget) const

Returns the SQL field that widget widget is mapped to.

QSqlField* QSqlForm::widgetToField ( QWidget widget) const
virtual void QSqlForm::writeField ( QWidget widget) [virtual, slot]
void QSqlForm::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 QSqlForm::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 QSqlCursor::insert(), QSqlCursor::update() or QSqlCursor::del() as appropriate.

virtual void QSqlForm::writeFields ( ) [virtual, slot]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'