You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
8.7 KiB
245 lines
8.7 KiB
'\" t
|
|
.TH TQSqlForm 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
TQSqlForm \- Creates and manages data entry forms tied to SQL databases
|
|
.SH SYNOPSIS
|
|
\fC#include <tqsqlform.h>\fR
|
|
.PP
|
|
Inherits TQObject.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBTQSqlForm\fR ( TQObject * parent = 0, const char * name = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fB~TQSqlForm\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBinsert\fR ( TQWidget * widget, const TQString & field )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBremove\fR ( const TQString & field )"
|
|
.br
|
|
.ti -1c
|
|
.BI "uint \fBcount\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQWidget * \fBwidget\fR ( uint i ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQSqlField * \fBwidgetToField\fR ( TQWidget * widget ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQWidget * \fBfieldToWidget\fR ( TQSqlField * field ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBinstallPropertyMap\fR ( TQSqlPropertyMap * pmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetRecord\fR ( TQSqlRecord * buf )"
|
|
.br
|
|
.in -1c
|
|
.SS "Public Slots"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "virtual void \fBreadField\fR ( TQWidget * widget )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBwriteField\fR ( TQWidget * widget )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBreadFields\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBwriteFields\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBclear\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBclearValues\fR ( bool nullify = FALSE )"
|
|
.br
|
|
.in -1c
|
|
.SS "Protected Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "virtual void \fBinsert\fR ( TQWidget * widget, TQSqlField * field )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBremove\fR ( TQWidget * widget )"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The TQSqlForm class creates and manages data entry forms tied to SQL databases.
|
|
.PP
|
|
Typical use of a TQSqlForm consists of the following steps:
|
|
.TP
|
|
Create the widgets you want to appear in the form.
|
|
.TP
|
|
Create a cursor and navigate to the record to be edited.
|
|
.TP
|
|
Create the TQSqlForm.
|
|
.TP
|
|
Set the form's record buffer to the cursor's update buffer.
|
|
.TP
|
|
Insert each widget and the field it is to edit into the form.
|
|
.TP
|
|
Use readFields() to update the editor widgets with values from the database's fields.
|
|
.TP
|
|
Display the form and let the user edit values etc.
|
|
.TP
|
|
Use writeFields() to update the database's field values with the values in the editor widgets.
|
|
.PP
|
|
Note that a TQSqlForm does not access the database directly, but most often via TQSqlFields which are part of a TQSqlCursor. A TQSqlCursor::insert(), TQSqlCursor::update() or TQSqlCursor::del() call is needed to actually write values to the database.
|
|
.PP
|
|
Some sample code to initialize a form successfully:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQLineEdit myEditor( this );
|
|
.br
|
|
TQSqlForm myForm( this );
|
|
.br
|
|
TQSqlCursor myCursor( "mytable" );
|
|
.br
|
|
.br
|
|
// Execute a query to make the cursor valid
|
|
.br
|
|
myCursor.select();
|
|
.br
|
|
// Move the cursor to a valid record (the first record)
|
|
.br
|
|
myCursor.next();
|
|
.br
|
|
// Set the form's record pointer to the cursor's edit buffer (which
|
|
.br
|
|
// contains the current record's values)
|
|
.br
|
|
myForm.setRecord( myCursor.primeUpdate() );
|
|
.br
|
|
.br
|
|
// Insert a field into the form that uses myEditor to edit the
|
|
.br
|
|
// field 'somefield' in 'mytable'
|
|
.br
|
|
myForm.insert( &myEditor, "somefield" );
|
|
.br
|
|
.br
|
|
// Update myEditor with the value from the mapped database field
|
|
.br
|
|
myForm.readFields();
|
|
.br
|
|
...
|
|
.br
|
|
// Let the user edit the form
|
|
.br
|
|
...
|
|
.br
|
|
// Update the database
|
|
.br
|
|
myForm.writeFields(); // Update the cursor's edit buffer from the form
|
|
.br
|
|
myCursor.update(); // Update the database from the cursor's buffer
|
|
.br
|
|
.fi
|
|
.PP
|
|
If you want to use custom editors for displaying and editing data fields, you must install a custom TQSqlPropertyMap. The form uses this object to get or set the value of a widget.
|
|
.PP
|
|
Note that TQt Designer provides a visual means of creating data-aware forms.
|
|
.PP
|
|
See also installPropertyMap(), TQSqlPropertyMap, and Database Classes.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "TQSqlForm::TQSqlForm ( TQObject * parent = 0, const char * name = 0 )"
|
|
Constructs a TQSqlForm with parent \fIparent\fR and called \fIname\fR.
|
|
.SH "TQSqlForm::~TQSqlForm ()"
|
|
Destroys the object and frees any allocated resources.
|
|
.SH "void TQSqlForm::clear ()\fC [virtual slot]\fR"
|
|
Removes every widget, and the fields they're mapped to, from the form.
|
|
.SH "void TQSqlForm::clearValues ( bool nullify = FALSE )\fC [virtual slot]\fR"
|
|
Clears the values in all the widgets, and the fields they are mapped to, in the form. If \fInullify\fR is TRUE (the default is FALSE), each field is also set to NULL.
|
|
.SH "uint TQSqlForm::count () const"
|
|
Returns the number of widgets in the form.
|
|
.SH "TQWidget * TQSqlForm::fieldToWidget ( TQSqlField * field ) const"
|
|
Returns the widget that field \fIfield\fR is mapped to.
|
|
.SH "void TQSqlForm::insert ( TQWidget * widget, const TQString & field )\fC [virtual]\fR"
|
|
Inserts a \fIwidget\fR, and the name of the \fIfield\fR it is to be mapped to, into the form. To actually associate inserted widgets with an edit buffer, use setRecord().
|
|
.PP
|
|
See also setRecord().
|
|
.PP
|
|
Examples:
|
|
.)l sql/overview/form1/main.cpp and sql/overview/form2/main.cpp.
|
|
.SH "void TQSqlForm::insert ( TQWidget * widget, TQSqlField * field )\fC [virtual protected]\fR"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Inserts a \fIwidget\fR, and the \fIfield\fR it is to be mapped to, into the form.
|
|
.SH "void TQSqlForm::installPropertyMap ( TQSqlPropertyMap * pmap )"
|
|
Installs a custom TQSqlPropertyMap. This is useful if you plan to create your own custom editor widgets.
|
|
.PP
|
|
TQSqlForm takes ownership of \fIpmap\fR, so \fIpmap\fR is deleted when TQSqlForm goes out of scope.
|
|
.PP
|
|
See also TQDataTable::installEditorFactory().
|
|
.PP
|
|
Example: sql/overview/custom1/main.cpp.
|
|
.SH "void TQSqlForm::readField ( TQWidget * widget )\fC [virtual slot]\fR"
|
|
Updates the widget \fIwidget\fR with the value from the SQL field it is mapped to. Nothing happens if no SQL field is mapped to the \fIwidget\fR.
|
|
.SH "void TQSqlForm::readFields ()\fC [virtual slot]\fR"
|
|
Updates the widgets in the form with current values from the SQL fields they are mapped to.
|
|
.PP
|
|
Examples:
|
|
.)l sql/overview/form1/main.cpp and sql/overview/form2/main.cpp.
|
|
.SH "void TQSqlForm::remove ( TQWidget * widget )\fC [virtual protected]\fR"
|
|
Removes a \fIwidget\fR, and hence the field it's mapped to, from the form.
|
|
.SH "void TQSqlForm::remove ( const TQString & field )\fC [virtual]\fR"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Removes \fIfield\fR from the form.
|
|
.SH "void TQSqlForm::setRecord ( TQSqlRecord * buf )\fC [virtual]\fR"
|
|
Sets \fIbuf\fR as the record buffer for the form. To force the display of the data from \fIbuf\fR, use readFields().
|
|
.PP
|
|
See also readFields() and writeFields().
|
|
.PP
|
|
Examples:
|
|
.)l sql/overview/custom1/main.cpp, sql/overview/form1/main.cpp, and sql/overview/form2/main.cpp.
|
|
.SH "TQWidget * TQSqlForm::widget ( uint i ) const"
|
|
Returns the \fIi\fR-th widget in the form. Useful for traversing the widgets in the form.
|
|
.SH "TQSqlField * TQSqlForm::widgetToField ( TQWidget * widget ) const"
|
|
Returns the SQL field that widget \fIwidget\fR is mapped to.
|
|
.SH "void TQSqlForm::writeField ( TQWidget * widget )\fC [virtual slot]\fR"
|
|
Updates the SQL field with the value from the \fIwidget\fR it is mapped to. Nothing happens if no SQL field is mapped to the \fIwidget\fR.
|
|
.SH "void TQSqlForm::writeFields ()\fC [virtual slot]\fR"
|
|
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 TQSqlCursor::insert(), TQSqlCursor::update() or TQSqlCursor::del() as appropriate.
|
|
.PP
|
|
Example: sql/overview/form2/main.cpp.
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/tqsqlform.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqsqlform.3qt) and the Qt
|
|
version (3.3.8).
|