📄 qsqlform.3qt
字号:
'\" t.TH QSqlForm 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQSqlForm \- Creates and manages data entry forms tied to SQL databases.SH SYNOPSIS\fC#include <qsqlform.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQSqlForm\fR ( QObject * parent = 0, const char * name = 0 )".br.ti -1c.BI "\fB~QSqlForm\fR ()".br.ti -1c.BI "virtual void \fBinsert\fR ( QWidget * widget, const QString & field )".br.ti -1c.BI "virtual void \fBremove\fR ( const QString & field )".br.ti -1c.BI "uint \fBcount\fR () const".br.ti -1c.BI "QWidget * \fBwidget\fR ( uint i ) const".br.ti -1c.BI "QSqlField * \fBwidgetToField\fR ( QWidget * widget ) const".br.ti -1c.BI "QWidget * \fBfieldToWidget\fR ( QSqlField * field ) const".br.ti -1c.BI "void \fBinstallPropertyMap\fR ( QSqlPropertyMap * pmap )".br.ti -1c.BI "virtual void \fBsetRecord\fR ( QSqlRecord * buf )".br.in -1c.SS "Public Slots".in +1c.ti -1c.BI "virtual void \fBreadField\fR ( QWidget * widget )".br.ti -1c.BI "virtual void \fBwriteField\fR ( QWidget * 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 ( QWidget * widget, QSqlField * field )".br.ti -1c.BI "virtual void \fBremove\fR ( QWidget * widget )".br.in -1c.SH DESCRIPTIONThe QSqlForm class creates and manages data entry forms tied to SQL databases..PPTypical use of a QSqlForm consists of the following steps:.TPCreate the widgets you want to appear in the form..TPCreate a cursor and navigate to the record to be edited..TPCreate the QSqlForm..TPSet the form's record buffer to the cursor's update buffer..TPInsert each widget and the field it is to edit into the form..TPUse readFields() to update the editor widgets with values from the database's fields..TPDisplay the form and let the user edit values etc..TPUse writeFields() to update the database's field values with the values in the editor widgets..PPNote 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..PPSome sample code to initialize a form successfully:.PP.nf.br QLineEdit myEditor( this );.br QSqlForm myForm( this );.br QSqlCursor 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.PPIf 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..PPNote that Qt Designer provides a visual means of creating data-aware forms..PPSee also installPropertyMap(), QSqlPropertyMap, and Database Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QSqlForm::QSqlForm ( QObject * parent = 0, const char * name = 0 )"Constructs a QSqlForm with parent \fIparent\fR and called \fIname\fR..SH "QSqlForm::~QSqlForm ()"Destroys the object and frees any allocated resources..SH "void QSqlForm::clear ()\fC [virtual slot]\fR"Removes every widget, and the fields they're mapped to, from the form..SH "void QSqlForm::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 QSqlForm::count () const"Returns the number of widgets in the form..SH "QWidget * QSqlForm::fieldToWidget ( QSqlField * field ) const"Returns the widget that field \fIfield\fR is mapped to..SH "void QSqlForm::insert ( QWidget * widget, const QString & 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()..PPSee also setRecord()..PPExamples:.)l sql/overview/form1/main.cpp and sql/overview/form2/main.cpp..SH "void QSqlForm::insert ( QWidget * widget, QSqlField * field )\fC [virtual protected]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a \fIwidget\fR, and the \fIfield\fR it is to be mapped to, into the form..SH "void QSqlForm::installPropertyMap ( QSqlPropertyMap * pmap )"Installs a custom QSqlPropertyMap. This is useful if you plan to create your own custom editor widgets..PPQSqlForm takes ownership of \fIpmap\fR, so \fIpmap\fR is deleted when QSqlForm goes out of scope..PPSee also QDataTable::installEditorFactory()..PPExample: sql/overview/custom1/main.cpp..SH "void QSqlForm::readField ( QWidget * 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 QSqlForm::readFields ()\fC [virtual slot]\fR"Updates the widgets in the form with current values from the SQL fields they are mapped to..PPExamples:.)l sql/overview/form1/main.cpp and sql/overview/form2/main.cpp..SH "void QSqlForm::remove ( QWidget * widget )\fC [virtual protected]\fR"Removes a \fIwidget\fR, and hence the field it's mapped to, from the form..SH "void QSqlForm::remove ( const QString & field )\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves \fIfield\fR from the form..SH "void QSqlForm::setRecord ( QSqlRecord * 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()..PPSee also readFields() and writeFields()..PPExamples:.)l sql/overview/custom1/main.cpp, sql/overview/form1/main.cpp, and sql/overview/form2/main.cpp..SH "QWidget * QSqlForm::widget ( uint i ) const"Returns the \fIi\fR-th widget in the form. Useful for traversing the widgets in the form..SH "QSqlField * QSqlForm::widgetToField ( QWidget * widget ) const"Returns the SQL field that widget \fIwidget\fR is mapped to..SH "void QSqlForm::writeField ( QWidget * 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 QSqlForm::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 QSqlCursor::insert(), QSqlCursor::update() or QSqlCursor::del() as appropriate..PPExample: sql/overview/form2/main.cpp..SH "SEE ALSO".BR http://doc.trolltech.com/qsqlform.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qsqlform.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -