<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/src/sql/tqsqlform.cpp:61 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > TQSqlForm Class< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > TQSqlForm Class Reference< br > < small > [< a href = "sql.html" > sql module< / a > ]< / small > < / h1 >
< p > The TQSqlForm class creates and manages data entry forms
tied to SQL databases.
< a href = "#details" > More...< / a >
< p > < tt > #include < < a href = "tqsqlform-h.html" > tqsqlform.h< / a > > < / tt >
< p > Inherits < a href = "tqobject.html" > TQObject< / a > .
< p > < a href = "tqsqlform-members.html" > List of all member functions.< / a >
< h2 > Public Members< / h2 >
< ul >
< li class = fn > < a href = "#TQSqlForm" > < b > TQSqlForm< / b > < / a > ( TQObject * parent = 0, const char * name = 0 )< / li >
< li class = fn > < a href = "#~TQSqlForm" > < b > ~TQSqlForm< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#insert" > < b > insert< / b > < / a > ( TQWidget * widget, const TQString & field )< / li >
< li class = fn > virtual void < a href = "#remove-2" > < b > remove< / b > < / a > ( const TQString & field )< / li >
< li class = fn > uint < a href = "#count" > < b > count< / b > < / a > () const< / li >
< li class = fn > TQWidget * < a href = "#widget" > < b > widget< / b > < / a > ( uint i ) const< / li >
< li class = fn > TQSqlField * < a href = "#widgetToField" > < b > widgetToField< / b > < / a > ( TQWidget * widget ) const< / li >
< li class = fn > TQWidget * < a href = "#fieldToWidget" > < b > fieldToWidget< / b > < / a > ( TQSqlField * field ) const< / li >
< li class = fn > void < a href = "#installPropertyMap" > < b > installPropertyMap< / b > < / a > ( TQSqlPropertyMap * pmap )< / li >
< li class = fn > virtual void < a href = "#setRecord" > < b > setRecord< / b > < / a > ( TQSqlRecord * buf )< / li >
< / ul >
< h2 > Public Slots< / h2 >
< ul >
< li class = fn > virtual void < a href = "#readField" > < b > readField< / b > < / a > ( TQWidget * widget )< / li >
< li class = fn > virtual void < a href = "#writeField" > < b > writeField< / b > < / a > ( TQWidget * widget )< / li >
< li class = fn > virtual void < a href = "#readFields" > < b > readFields< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#writeFields" > < b > writeFields< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#clear" > < b > clear< / b > < / a > ()< / li >
< li class = fn > virtual void < a href = "#clearValues" > < b > clearValues< / b > < / a > ( bool nullify = FALSE )< / li >
< / ul >
< h2 > Protected Members< / h2 >
< ul >
< li class = fn > virtual void < a href = "#insert-2" > < b > insert< / b > < / a > ( TQWidget * widget, TQSqlField * field )< / li >
< li class = fn > virtual void < a href = "#remove" > < b > remove< / b > < / a > ( TQWidget * widget )< / li >
< / ul >
< hr > < a name = "details" > < / a > < h2 > Detailed Description< / h2 >
The TQSqlForm class creates and manages data entry forms
tied to SQL databases.
< p >
< p > Typical use of a TQSqlForm consists of the following steps:
< ul >
< li > Create the widgets you want to appear in the form.
< li > Create a cursor and navigate to the record to be edited.
< li > Create the TQSqlForm.
< li > Set the form's record buffer to the cursor's update buffer.
< li > Insert each widget and the field it is to edit into the form.
< li > Use < a href = "#readFields" > readFields< / a > () to update the editor widgets with values from
the database's fields.
< li > Display the form and let the user edit values etc.
< li > Use < a href = "#writeFields" > writeFields< / a > () to update the database's field values with
the values in the editor widgets.
< / ul >
< p > Note that a TQSqlForm does not access the database directly, but
most often via TQSqlFields which are part of a < a href = "tqsqlcursor.html" > TQSqlCursor< / a > . A
< a href = "tqsqlcursor.html#insert" > TQSqlCursor::insert< / a > (), < a href = "tqsqlcursor.html#update" > TQSqlCursor::update< / a > () or < a href = "tqsqlcursor.html#del" > TQSqlCursor::del< / a > ()
call is needed to actually write values to the database.
< p > Some sample code to initialize a form successfully:
< p > < pre >
< a href = "ntqlineedit.html" > TQLineEdit< / a > myEditor( this );
TQSqlForm myForm( this );
< a href = "tqsqlcursor.html" > TQSqlCursor< / a > myCursor( "mytable" );
// Execute a query to make the cursor valid
myCursor.< a href = "tqsqlcursor.html#select" > select< / a > ();
// Move the cursor to a valid record (the first record)
myCursor.< a href = "tqsqlquery.html#next" > next< / a > ();
// Set the form's record pointer to the cursor's edit buffer (which
// contains the current record's values)
myForm.< a href = "#setRecord" > setRecord< / a > ( myCursor.< a href = "tqsqlcursor.html#primeUpdate" > primeUpdate< / a > () );
// Insert a field into the form that uses myEditor to edit the
// field 'somefield' in 'mytable'
myForm.< a href = "#insert" > insert< / a > ( & myEditor, "somefield" );
// Update myEditor with the value from the mapped database field
myForm.< a href = "#readFields" > readFields< / a > ();
...
// Let the user edit the form
...
// Update the database
myForm.< a href = "#writeFields" > writeFields< / a > (); // Update the cursor's edit buffer from the form
myCursor.< a href = "tqsqlcursor.html#update" > update< / a > (); // Update the database from the cursor's buffer
< / pre >
< p > If you want to use custom editors for displaying and editing data
fields, you must install a custom < a href = "tqsqlpropertymap.html" > TQSqlPropertyMap< / a > . The form
uses this object to get or set the value of a widget.
< p > Note that < a href = "designer-manual.html" > TQt Designer< / a > provides
a visual means of creating data-aware forms.
< p > < p > See also < a href = "#installPropertyMap" > installPropertyMap< / a > (), < a href = "tqsqlpropertymap.html" > TQSqlPropertyMap< / a > , and < a href = "database.html" > Database Classes< / a > .
< hr > < h2 > Member Function Documentation< / h2 >
< h3 class = fn > < a name = "TQSqlForm" > < / a > TQSqlForm::TQSqlForm ( < a href = "tqobject.html" > TQObject< / a > * parent = 0, const char * name = 0 )
< / h3 >
Constructs a TQSqlForm with parent < em > parent< / em > and called < em > name< / em > .
< h3 class = fn > < a name = "~TQSqlForm" > < / a > TQSqlForm::~TQSqlForm ()
< / h3 >
Destroys the object and frees any allocated resources.
< h3 class = fn > void < a name = "clear" > < / a > TQSqlForm::clear ()< tt > [virtual slot]< / tt >
< / h3 >
Removes every widget, and the fields they're mapped to, from the form.
< h3 class = fn > void < a name = "clearValues" > < / a > TQSqlForm::clearValues ( bool nullify = FALSE )< tt > [virtual slot]< / tt >
< / h3 >
Clears the values in all the widgets, and the fields they are
mapped to, in the form. If < em > nullify< / em > is TRUE (the default is
FALSE), each field is also set to NULL.
< h3 class = fn > uint < a name = "count" > < / a > TQSqlForm::count () const
< / h3 >
Returns the number of widgets in the form.
< h3 class = fn > < a href = "tqwidget.html" > TQWidget< / a > * < a name = "fieldToWidget" > < / a > TQSqlForm::fieldToWidget ( < a href = "tqsqlfield.html" > TQSqlField< / a > * field ) const
< / h3 >
Returns the widget that field < em > field< / em > is mapped to.
< h3 class = fn > void < a name = "insert" > < / a > TQSqlForm::insert ( < a href = "tqwidget.html" > TQWidget< / a > * widget, const < a href = "ntqstring.html" > TQString< / a > & field )< tt > [virtual]< / tt >
< / h3 >
Inserts a < em > widget< / em > , and the name of the < em > field< / em > it is to be
mapped to, into the form. To actually associate inserted widgets
with an edit buffer, use < a href = "#setRecord" > setRecord< / a > ().
< p > < p > See also < a href = "#setRecord" > setRecord< / a > ().
< p > Examples: < a href = "sql.html#x2225" > sql/overview/form1/main.cpp< / a > and < a href = "sql.html#x2231" > sql/overview/form2/main.cpp< / a > .
< h3 class = fn > void < a name = "insert-2" > < / a > TQSqlForm::insert ( < a href = "tqwidget.html" > TQWidget< / a > * widget, < a href = "tqsqlfield.html" > TQSqlField< / a > * field )< tt > [virtual protected]< / tt >
< / h3 >
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
< p > Inserts a < em > widget< / em > , and the < em > field< / em > it is to be mapped to, into
the form.
< h3 class = fn > void < a name = "installPropertyMap" > < / a > TQSqlForm::installPropertyMap ( < a href = "tqsqlpropertymap.html" > TQSqlPropertyMap< / a > * pmap )
< / h3 >
Installs a custom < a href = "tqsqlpropertymap.html" > TQSqlPropertyMap< / a > . This is useful if you plan to
create your own custom editor widgets.
< p > TQSqlForm takes ownership of < em > pmap< / em > , so < em > pmap< / em > is deleted when
TQSqlForm goes out of scope.
< p > < p > See also < a href = "tqdatatable.html#installEditorFactory" > TQDataTable::installEditorFactory< / a > ().
< p > Example: < a href = "sql.html#x2237" > sql/overview/custom1/main.cpp< / a > .
< h3 class = fn > void < a name = "readField" > < / a > TQSqlForm::readField ( < a href = "tqwidget.html" > TQWidget< / a > * widget )< tt > [virtual slot]< / tt >
< / h3 >
Updates the widget < em > widget< / em > with the value from the SQL field it
is mapped to. Nothing happens if no SQL field is mapped to the < em > widget< / em > .
< h3 class = fn > void < a name = "readFields" > < / a > TQSqlForm::readFields ()< tt > [virtual slot]< / tt >
< / h3 >
Updates the widgets in the form with current values from the SQL
fields they are mapped to.
< p > Examples: < a href = "sql.html#x2226" > sql/overview/form1/main.cpp< / a > and < a href = "sql.html#x2232" > sql/overview/form2/main.cpp< / a > .
< h3 class = fn > void < a name = "remove" > < / a > TQSqlForm::remove ( < a href = "tqwidget.html" > TQWidget< / a > * widget )< tt > [virtual protected]< / tt >
< / h3 >
Removes a < em > widget< / em > , and hence the field it's mapped to, from the
form.
< h3 class = fn > void < a name = "remove-2" > < / a > TQSqlForm::remove ( const < a href = "ntqstring.html" > TQString< / a > & field )< tt > [virtual]< / tt >
< / h3 >
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
< p > Removes < em > field< / em > from the form.
< h3 class = fn > void < a name = "setRecord" > < / a > TQSqlForm::setRecord ( < a href = "tqsqlrecord.html" > TQSqlRecord< / a > * buf )< tt > [virtual]< / tt >
< / h3 >
Sets < em > buf< / em > as the record buffer for the form. To force the
display of the data from < em > buf< / em > , use < a href = "#readFields" > readFields< / a > ().
< p > < p > See also < a href = "#readFields" > readFields< / a > () and < a href = "#writeFields" > writeFields< / a > ().
< p > Examples: < a href = "sql.html#x2238" > sql/overview/custom1/main.cpp< / a > , < a href = "sql.html#x2227" > sql/overview/form1/main.cpp< / a > , and < a href = "sql.html#x2233" > sql/overview/form2/main.cpp< / a > .
< h3 class = fn > < a href = "tqwidget.html" > TQWidget< / a > * < a name = "widget" > < / a > TQSqlForm::widget ( uint i ) const
< / h3 >
Returns the < em > i< / em > -th widget in the form. Useful for traversing
the widgets in the form.
< h3 class = fn > < a href = "tqsqlfield.html" > TQSqlField< / a > * < a name = "widgetToField" > < / a > TQSqlForm::widgetToField ( < a href = "tqwidget.html" > TQWidget< / a > * widget ) const
< / h3 >
Returns the SQL field that widget < em > widget< / em > is mapped to.
< h3 class = fn > void < a name = "writeField" > < / a > TQSqlForm::writeField ( < a href = "tqwidget.html" > TQWidget< / a > * widget )< tt > [virtual slot]< / tt >
< / h3 >
Updates the SQL field with the value from the < em > widget< / em > it is
mapped to. Nothing happens if no SQL field is mapped to the < em > widget< / em > .
< h3 class = fn > void < a name = "writeFields" > < / a > TQSqlForm::writeFields ()< tt > [virtual slot]< / tt >
< / h3 >
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 < a href = "tqsqlcursor.html#insert" > TQSqlCursor::insert< / a > (), < a href = "tqsqlcursor.html#update" > TQSqlCursor::update< / a > ()
or < a href = "tqsqlcursor.html#del" > TQSqlCursor::del< / a > () as appropriate.
< p > Example: < a href = "sql.html#x2234" > sql/overview/form2/main.cpp< / a > .
<!-- eof -->
< hr > < p >
This file is part of the < a href = "index.html" > TQt toolkit< / a > .
Copyright © 1995-2007
< a href = "http://www.trolltech.com/" > Trolltech< / a > . All Rights Reserved.< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >