diff options
Diffstat (limited to 'doc/html/qsqlform.html')
-rw-r--r-- | doc/html/qsqlform.html | 237 |
1 files changed, 237 insertions, 0 deletions
diff --git a/doc/html/qsqlform.html b/doc/html/qsqlform.html new file mode 100644 index 0000000..e4fbc2a --- /dev/null +++ b/doc/html/qsqlform.html @@ -0,0 +1,237 @@ +<!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/qsqlform.cpp:61 --> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>QSqlForm 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>QSqlForm Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1> + +<p>The QSqlForm class creates and manages data entry forms +tied to SQL databases. +<a href="#details">More...</a> +<p><tt>#include <<a href="qsqlform-h.html">qsqlform.h</a>></tt> +<p>Inherits <a href="qobject.html">QObject</a>. +<p><a href="qsqlform-members.html">List of all member functions.</a> +<h2>Public Members</h2> +<ul> +<li class=fn><a href="#QSqlForm"><b>QSqlForm</b></a> ( QObject * parent = 0, const char * name = 0 )</li> +<li class=fn><a href="#~QSqlForm"><b>~QSqlForm</b></a> ()</li> +<li class=fn>virtual void <a href="#insert"><b>insert</b></a> ( QWidget * widget, const QString & field )</li> +<li class=fn>virtual void <a href="#remove-2"><b>remove</b></a> ( const QString & field )</li> +<li class=fn>uint <a href="#count"><b>count</b></a> () const</li> +<li class=fn>QWidget * <a href="#widget"><b>widget</b></a> ( uint i ) const</li> +<li class=fn>QSqlField * <a href="#widgetToField"><b>widgetToField</b></a> ( QWidget * widget ) const</li> +<li class=fn>QWidget * <a href="#fieldToWidget"><b>fieldToWidget</b></a> ( QSqlField * field ) const</li> +<li class=fn>void <a href="#installPropertyMap"><b>installPropertyMap</b></a> ( QSqlPropertyMap * pmap )</li> +<li class=fn>virtual void <a href="#setRecord"><b>setRecord</b></a> ( QSqlRecord * buf )</li> +</ul> +<h2>Public Slots</h2> +<ul> +<li class=fn>virtual void <a href="#readField"><b>readField</b></a> ( QWidget * widget )</li> +<li class=fn>virtual void <a href="#writeField"><b>writeField</b></a> ( QWidget * 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> ( QWidget * widget, QSqlField * field )</li> +<li class=fn>virtual void <a href="#remove"><b>remove</b></a> ( QWidget * widget )</li> +</ul> +<hr><a name="details"></a><h2>Detailed Description</h2> + + +The QSqlForm class creates and manages data entry forms +tied to SQL databases. +<p> + + +<p> Typical use of a QSqlForm 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 QSqlForm. +<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 QSqlForm does not access the database directly, but +most often via QSqlFields which are part of a <a href="qsqlcursor.html">QSqlCursor</a>. A +<a href="qsqlcursor.html#insert">QSqlCursor::insert</a>(), <a href="qsqlcursor.html#update">QSqlCursor::update</a>() or <a href="qsqlcursor.html#del">QSqlCursor::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="qlineedit.html">QLineEdit</a> myEditor( this ); + QSqlForm myForm( this ); + <a href="qsqlcursor.html">QSqlCursor</a> myCursor( "mytable" ); + + // Execute a query to make the cursor valid + myCursor.<a href="qsqlcursor.html#select">select</a>(); + // Move the cursor to a valid record (the first record) + myCursor.<a href="qsqlquery.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="qsqlcursor.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="qsqlcursor.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="qsqlpropertymap.html">QSqlPropertyMap</a>. The form +uses this object to get or set the value of a widget. +<p> Note that <a href="designer-manual.html">Qt Designer</a> provides +a visual means of creating data-aware forms. +<p> <p>See also <a href="#installPropertyMap">installPropertyMap</a>(), <a href="qsqlpropertymap.html">QSqlPropertyMap</a>, and <a href="database.html">Database Classes</a>. + +<hr><h2>Member Function Documentation</h2> +<h3 class=fn><a name="QSqlForm"></a>QSqlForm::QSqlForm ( <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 ) +</h3> +Constructs a QSqlForm with parent <em>parent</em> and called <em>name</em>. + +<h3 class=fn><a name="~QSqlForm"></a>QSqlForm::~QSqlForm () +</h3> +Destroys the object and frees any allocated resources. + +<h3 class=fn>void <a name="clear"></a>QSqlForm::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>QSqlForm::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>QSqlForm::count () const +</h3> +Returns the number of widgets in the form. + +<h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="fieldToWidget"></a>QSqlForm::fieldToWidget ( <a href="qsqlfield.html">QSqlField</a> * field ) const +</h3> +Returns the widget that field <em>field</em> is mapped to. + +<h3 class=fn>void <a name="insert"></a>QSqlForm::insert ( <a href="qwidget.html">QWidget</a> * widget, const <a href="qstring.html">QString</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>QSqlForm::insert ( <a href="qwidget.html">QWidget</a> * widget, <a href="qsqlfield.html">QSqlField</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>QSqlForm::installPropertyMap ( <a href="qsqlpropertymap.html">QSqlPropertyMap</a> * pmap ) +</h3> +Installs a custom <a href="qsqlpropertymap.html">QSqlPropertyMap</a>. This is useful if you plan to +create your own custom editor widgets. +<p> QSqlForm takes ownership of <em>pmap</em>, so <em>pmap</em> is deleted when +QSqlForm goes out of scope. +<p> <p>See also <a href="qdatatable.html#installEditorFactory">QDataTable::installEditorFactory</a>(). + +<p>Example: <a href="sql.html#x2237">sql/overview/custom1/main.cpp</a>. +<h3 class=fn>void <a name="readField"></a>QSqlForm::readField ( <a href="qwidget.html">QWidget</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>QSqlForm::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>QSqlForm::remove ( <a href="qwidget.html">QWidget</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>QSqlForm::remove ( const <a href="qstring.html">QString</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>QSqlForm::setRecord ( <a href="qsqlrecord.html">QSqlRecord</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="qwidget.html">QWidget</a> * <a name="widget"></a>QSqlForm::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="qsqlfield.html">QSqlField</a> * <a name="widgetToField"></a>QSqlForm::widgetToField ( <a href="qwidget.html">QWidget</a> * widget ) const +</h3> +Returns the SQL field that widget <em>widget</em> is mapped to. + +<h3 class=fn>void <a name="writeField"></a>QSqlForm::writeField ( <a href="qwidget.html">QWidget</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>QSqlForm::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="qsqlcursor.html#insert">QSqlCursor::insert</a>(), <a href="qsqlcursor.html#update">QSqlCursor::update</a>() +or <a href="qsqlcursor.html#del">QSqlCursor::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">Qt 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>Qt 3.3.8</div> +</table></div></address></body> +</html> |