1QSqlForm(3qt)                                                    QSqlForm(3qt)
2
3
4

NAME

6       QSqlForm - Creates and manages data entry forms tied to SQL databases
7

SYNOPSIS

9       #include <qsqlform.h>
10
11       Inherits QObject.
12
13   Public Members
14       QSqlForm ( QObject * parent = 0, const char * name = 0 )
15       ~QSqlForm ()
16       virtual void insert ( QWidget * widget, const QString & field )
17       virtual void remove ( const QString & field )
18       uint count () const
19       QWidget * widget ( uint i ) const
20       QSqlField * widgetToField ( QWidget * widget ) const
21       QWidget * fieldToWidget ( QSqlField * field ) const
22       void installPropertyMap ( QSqlPropertyMap * pmap )
23       virtual void setRecord ( QSqlRecord * buf )
24
25   Public Slots
26       virtual void readField ( QWidget * widget )
27       virtual void writeField ( QWidget * widget )
28       virtual void readFields ()
29       virtual void writeFields ()
30       virtual void clear ()
31       virtual void clearValues ( bool nullify = FALSE )
32
33   Protected Members
34       virtual void insert ( QWidget * widget, QSqlField * field )
35       virtual void remove ( QWidget * widget )
36

DESCRIPTION

38       The QSqlForm class creates and manages data entry forms tied to SQL
39       databases.
40
41       Typical use of a QSqlForm consists of the following steps:
42
43       Create the widgets you want to appear in the form.
44
45       Create a cursor and navigate to the record to be edited.
46
47       Create the QSqlForm.
48
49       Set the form's record buffer to the cursor's update buffer.
50
51       Insert each widget and the field it is to edit into the form.
52
53       Use readFields() to update the editor widgets with values from the
54       database's fields.
55
56       Display the form and let the user edit values etc.
57
58       Use writeFields() to update the database's field values with the values
59       in the editor widgets.
60
61       Note that a QSqlForm does not access the database directly, but most
62       often via QSqlFields which are part of a QSqlCursor. A
63       QSqlCursor::insert(), QSqlCursor::update() or QSqlCursor::del() call is
64       needed to actually write values to the database.
65
66       Some sample code to initialize a form successfully:
67
68           QLineEdit  myEditor( this );
69           QSqlForm   myForm( this );
70           QSqlCursor myCursor( "mytable" );
71           // Execute a query to make the cursor valid
72           myCursor.select();
73           // Move the cursor to a valid record (the first record)
74           myCursor.next();
75           // Set the form's record pointer to the cursor's edit buffer (which
76           // contains the current record's values)
77           myForm.setRecord( myCursor.primeUpdate() );
78           // Insert a field into the form that uses myEditor to edit the
79           // field 'somefield' in 'mytable'
80           myForm.insert( &myEditor, "somefield" );
81           // Update myEditor with the value from the mapped database field
82           myForm.readFields();
83           ...
84           // Let the user edit the form
85           ...
86           // Update the database
87           myForm.writeFields();  // Update the cursor's edit buffer from the form
88           myCursor.update();  // Update the database from the cursor's buffer
89
90       If you want to use custom editors for displaying and editing data
91       fields, you must install a custom QSqlPropertyMap. The form uses this
92       object to get or set the value of a widget.
93
94       Note that Qt Designer provides a visual means of creating data-aware
95       forms.
96
97       See also installPropertyMap(), QSqlPropertyMap, and Database Classes.
98

MEMBER FUNCTION DOCUMENTATION

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

101       Constructs a QSqlForm with parent parent and called name.
102

QSqlForm::~QSqlForm ()

104       Destroys the object and frees any allocated resources.
105

void QSqlForm::clear () [virtual slot]

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

void QSqlForm::clearValues ( bool nullify = FALSE ) [virtual slot]

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

uint QSqlForm::count () const

115       Returns the number of widgets in the form.
116

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

118       Returns the widget that field field is mapped to.
119

void QSqlForm::insert ( QWidget * widget, const QString & field ) [virtual]

121       Inserts a widget, and the name of the field it is to be mapped to, into
122       the form. To actually associate inserted widgets with an edit buffer,
123       use setRecord().
124
125       See also setRecord().
126
127       Examples:
128

void QSqlForm::insert ( QWidget * widget, QSqlField * field ) [virtual

130       protected]
131       This is an overloaded member function, provided for convenience. It
132       behaves essentially like the above function.
133
134       Inserts a widget, and the field it is to be mapped to, into the form.
135

void QSqlForm::installPropertyMap ( QSqlPropertyMap * pmap )

137       Installs a custom QSqlPropertyMap. This is useful if you plan to create
138       your own custom editor widgets.
139
140       QSqlForm takes ownership of pmap, so pmap is deleted when QSqlForm goes
141       out of scope.
142
143       See also QDataTable::installEditorFactory().
144
145       Example: sql/overview/custom1/main.cpp.
146

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

148       Updates the widget widget with the value from the SQL field it is
149       mapped to. Nothing happens if no SQL field is mapped to the widget.
150

void QSqlForm::readFields () [virtual slot]

152       Updates the widgets in the form with current values from the SQL fields
153       they are mapped to.
154
155       Examples:
156

void QSqlForm::remove ( QWidget * widget ) [virtual protected]

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

void QSqlForm::remove ( const QString & field ) [virtual]

161       This is an overloaded member function, provided for convenience. It
162       behaves essentially like the above function.
163
164       Removes field from the form.
165

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

167       Sets buf as the record buffer for the form. To force the display of the
168       data from buf, use readFields().
169
170       See also readFields() and writeFields().
171
172       Examples:
173

QWidget * QSqlForm::widget ( uint i ) const

175       Returns the i-th widget in the form. Useful for traversing the widgets
176       in the form.
177

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

179       Returns the SQL field that widget widget is mapped to.
180

void QSqlForm::writeField ( QWidget * widget ) [virtual slot]

182       Updates the SQL field with the value from the widget it is mapped to.
183       Nothing happens if no SQL field is mapped to the widget.
184

void QSqlForm::writeFields () [virtual slot]

186       Updates the SQL fields with values from the widgets they are mapped to.
187       To actually update the database with the contents of the record buffer,
188       use QSqlCursor::insert(), QSqlCursor::update() or QSqlCursor::del() as
189       appropriate.
190
191       Example: sql/overview/form2/main.cpp.
192
193

SEE ALSO

195       http://doc.trolltech.com/qsqlform.html
196       http://www.trolltech.com/faq/tech.html
197
199       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
200       license file included in the distribution for a complete license
201       statement.
202

AUTHOR

204       Generated automatically from the source code.
205

BUGS

207       If you find a bug in Qt, please report it as described in
208       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
209       help you. Thank you.
210
211       The definitive Qt documentation is provided in HTML format; it is
212       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
213       web browser. This man page is provided as a convenience for those users
214       who prefer man pages, although this format is not officially supported
215       by Trolltech.
216
217       If you find errors in this manual page, please report them to qt-
218       bugs@trolltech.com.  Please include the name of the manual page
219       (qsqlform.3qt) and the Qt version (3.3.8).
220
221
222
223Trolltech AS                    2 February 2007                  QSqlForm(3qt)
Impressum