⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdatabrowser.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 3 页
字号:
.br.ti -1c.BI "bool \fBconfirmCancels\fR - whether the browser confirms cancel operations".br.ti -1c.BI "bool \fBconfirmDelete\fR - whether the browser confirms deletions".br.ti -1c.BI "bool \fBconfirmEdits\fR - whether the browser confirms edit operations".br.ti -1c.BI "bool \fBconfirmInsert\fR - whether the data browser confirms insertions".br.ti -1c.BI "bool \fBconfirmUpdate\fR - whether the browser confirms updates".br.ti -1c.BI "QString \fBfilter\fR - the data browser's filter".br.ti -1c.BI "bool \fBreadOnly\fR - whether the browser is read-only".br.ti -1c.BI "QStringList \fBsort\fR - the data browser's sort".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual bool \fBinsertCurrent\fR ()".br.ti -1c.BI "virtual bool \fBupdateCurrent\fR ()".br.ti -1c.BI "virtual bool \fBdeleteCurrent\fR ()".br.ti -1c.BI "virtual bool \fBcurrentEdited\fR ()".br.ti -1c.BI "virtual QSql::Confirm \fBconfirmEdit\fR ( QSql::Op m )".br.ti -1c.BI "virtual QSql::Confirm \fBconfirmCancel\fR ( QSql::Op m )".br.ti -1c.BI "virtual void \fBhandleError\fR ( const QSqlError & error )".br.in -1c.SH DESCRIPTIONThe QDataBrowser class provides data manipulation and navigation for data entry forms..PPA high-level API is provided to navigate through data records in a cursor, insert, update and delete records, and refresh data in the display..PPIf you want a read-only form to present database data use QDataView; if you want a table-based presentation of your data use QDataTable..PPA QDataBrowser is used to associate a dataset with a form in much the same way as a QDataTable associates a dataset with a table. Once the data browser has been constructed it can be associated with a dataset with setSqlCursor(), and with a form with setForm(). Boundary checking, sorting and filtering can be set with setBoundaryChecking(), setSort() and setFilter(), respectively..PPThe insertCurrent() function reads the fields from the default form into the default cursor and performs the insert. The updateCurrent() and deleteCurrent() functions perform similarly to update and delete the current record respectively..PPThe user can be asked to confirm all edits with setConfirmEdits(). For more precise control use setConfirmInsert(), setConfirmUpdate(), setConfirmDelete() and setConfirmCancels(). Use setAutoEdit() to control the behaviour of the form when the user edits a record and then navigates..PPThe record set is navigated using first(), next(), prev(), last() and seek(). The form's display is updated with refresh(). When navigation takes place the firstRecordAvailable(), lastRecordAvailable(), nextRecordAvailable() and prevRecordAvailable() signals are emitted. When the cursor record is changed due to navigation the cursorChanged() signal is emitted..PPIf you want finer control of the insert, update and delete processes then you can use the low level functions to perform these operations as described below..PPThe form is populated with data from the database with readFields(). If the user is allowed to edit, (see setReadOnly()), write the form's data back to the cursor's edit buffer with writeFields(). You can clear the values in the form with clearValues(). Editing is performed as follows:.TP\fIinsert\fR When the data browser enters insertion mode it emits the primeInsert() signal which you can connect to, for example to pre-populate fields. Call writeFields() to write the user's edits to the cursor's edit buffer then call insert() to insert the record into the database. The beforeInsert() signal is emitted just before the cursor's edit buffer is inserted into the database; connect to this for example, to populate fields such as an auto-generated primary key..TP\fIupdate\fR For updates the primeUpdate() signal is emitted when the data browser enters update mode. After calling writeFields() call update() to update the record and connect to the beforeUpdate() signal to manipulate the user's data before the update takes place..TP\fIdelete\fR For deletion the primeDelete() signal is emitted when the data browser enters deletion mode. After calling writeFields() call del() to delete the record and connect to the beforeDelete() signal, for example to record an audit of the deleted record..PPSee also Database Classes..SS "Member Type Documentation".SH "QDataBrowser::Boundary"This enum describes where the data browser is positioned..PPThe currently defined values are:.TP\fCQDataBrowser::Unknown\fR - the boundary cannot be determined (usually because there is no default cursor, or the default cursor is not active)..TP\fCQDataBrowser::None\fR - the browser is not positioned on a boundary, but it is positioned on a record somewhere in the middle..TP\fCQDataBrowser::BeforeBeginning\fR - the browser is positioned before the first available record..TP\fCQDataBrowser::Beginning\fR - the browser is positioned at the first record..TP\fCQDataBrowser::End\fR - the browser is positioned at the last record..TP\fCQDataBrowser::AfterEnd\fR - the browser is positioned after the last available record..SH MEMBER FUNCTION DOCUMENTATION.SH "QDataBrowser::QDataBrowser ( QWidget * parent = 0, const char * name = 0, WFlags fl = 0 )"Constructs a data browser which is a child of \fIparent\fR, with the name \fIname\fR and widget flags set to \fIfl\fR..SH "QDataBrowser::~QDataBrowser ()"Destroys the object and frees any allocated resources..SH "bool QDataBrowser::autoEdit () const"Returns TRUE if the browser automatically applies edits; otherwise returns FALSE. See the "autoEdit" property for details..SH "void QDataBrowser::beforeDelete ( QSqlRecord * buf )\fC [signal]\fR"This signal is emitted just before the cursor's edit buffer is deleted from the database. The \fIbuf\fR parameter points to the edit buffer being deleted. You might connect to this signal to capture some auditing information about the deletion..SH "void QDataBrowser::beforeInsert ( QSqlRecord * buf )\fC [signal]\fR"This signal is emitted just before the cursor's edit buffer is inserted into the database. The \fIbuf\fR parameter points to the edit buffer being inserted. You might connect to this signal to populate a generated primary key for example..SH "void QDataBrowser::beforeUpdate ( QSqlRecord * buf )\fC [signal]\fR"This signal is emitted just before the cursor's edit buffer is updated in the database. The \fIbuf\fR parameter points to the edit buffer being updated. You might connect to this signal to capture some auditing information about the update..SH "Boundary QDataBrowser::boundary ()"Returns an enum indicating the boundary status of the browser..PPThis is achieved by moving the default cursor and checking the position, however the current default form values will not be altered. After checking for the boundary, the cursor is moved back to its former position. See QDataBrowser::Boundary..PPSee also Boundary..SH "bool QDataBrowser::boundaryChecking () const"Returns TRUE if boundary checking is active; otherwise returns FALSE. See the "boundaryChecking" property for details..SH "void QDataBrowser::clearValues ()\fC [virtual slot]\fR"Clears all the values in the form..PPAll the edit buffer field values are set to their 'zero state', e.g. 0 for numeric fields and "" for string fields. Then the widgets are updated using the property map. For example, a combobox that is property-mapped to integers would scroll to the first item. See the QSqlPropertyMap constructor for the default mappings of widgets to properties..SH "QSql::Confirm QDataBrowser::confirmCancel ( QSql::Op m )\fC [virtual protected]\fR"Protected virtual function which returns a confirmation for cancelling an edit mode \fIm\fR. Derived classes can reimplement this function and provide their own confirmation dialog. The default implementation uses a message box which prompts the user to confirm the edit action..SH "bool QDataBrowser::confirmCancels () const"Returns TRUE if the browser confirms cancel operations; otherwise returns FALSE. See the "confirmCancels" property for details..SH "bool QDataBrowser::confirmDelete () const"Returns TRUE if the browser confirms deletions; otherwise returns FALSE. See the "confirmDelete" property for details..SH "QSql::Confirm QDataBrowser::confirmEdit ( QSql::Op m )\fC [virtual protected]\fR"Protected virtual function which returns a confirmation for an edit of mode \fIm\fR. Derived classes can reimplement this function and provide their own confirmation dialog. The default implementation uses a message box which prompts the user to confirm the edit action..SH "bool QDataBrowser::confirmEdits () const"Returns TRUE if the browser confirms edit operations; otherwise returns FALSE. See the "confirmEdits" property for details..SH "bool QDataBrowser::confirmInsert () const"Returns TRUE if the data browser confirms insertions; otherwise returns FALSE. See the "confirmInsert" property for details..SH "bool QDataBrowser::confirmUpdate () const"Returns TRUE if the browser confirms updates; otherwise returns FALSE. See the "confirmUpdate" property for details..SH "void QDataBrowser::currentChanged ( const QSqlRecord * record )\fC [signal]\fR"This signal is emitted whenever the current cursor position changes. The \fIrecord\fR parameter points to the contents of the current cursor's record..SH "bool QDataBrowser::currentEdited ()\fC [virtual protected]\fR"Returns TRUE if the form's edit buffer differs from the current cursor buffer, otherwise FALSE is returned..SH "void QDataBrowser::cursorChanged ( QSqlCursor::Mode mode )\fC [signal]\fR"This signal is emitted whenever the cursor record was changed due to navigation. The \fImode\fR parameter is the edit that just took place, e.g. Insert, Update or Delete. See QSqlCursor::Mode..SH "void QDataBrowser::del ()\fC [virtual slot]\fR"Performs a delete operation on the data browser's cursor. If there is no default cursor or no default form, nothing happens..PPOtherwise, the following happens:.PPThe current form's record is deleted from the database, providing that the data browser is not in insert mode. If the data browser is actively inserting a record (see insert()), the insert action is cancelled, and the browser navigates to the last valid record that was current. If there is an error, handleError() is called..SH "bool QDataBrowser::deleteCurrent ()\fC [virtual protected]\fR"Performs a delete on the default cursor using the values from the default form and updates the default form. If there is no default form or no default cursor, nothing happens. If the deletion was successful, the cursor is repositioned to the nearest record and TRUE is returned. The nearest record is the next record if there is one otherwise the previous record if there is one. If an error occurred during the deletion from the database, handleError() is called and FALSE is returned..PPSee also cursor, form() and handleError()..SH "QString QDataBrowser::filter () const"Returns the data browser's filter. See the "filter" property for details..SH "void QDataBrowser::first ()\fC [virtual slot]\fR"Moves the default cursor to the first record and refreshes the default form to display this record. If there is no default form or no default cursor, nothing happens. If the data browser successfully navigated to the first record, the default cursor is primed for update and the primeUpdate() signal is emitted..PPIf the browser is already positioned on the first record nothing happens..SH "void QDataBrowser::firstRecordAvailable ( bool available )\fC [signal]\fR"This signal is emitted whenever the position of the cursor changes. The \fIavailable\fR parameter indicates whether or not the first record in the default cursor is available..SH "QSqlForm * QDataBrowser::form ()"Returns a pointer to the data browser's default form or 0 if no form has been set..SH "void QDataBrowser::handleError ( const QSqlError & error )\fC [virtual protected]\fR"Virtual function which handles the error \fIerror\fR. The default implementation warns the user with a message box..SH "void QDataBrowser::insert ()\fC [virtual slot]\fR"Performs an insert operation on the data browser's cursor. If there is no default cursor or no default form, nothing happens..PPIf auto-editing is on (see setAutoEdit()), the following happens:.TPIf the browser is already actively inserting a record, the current form's data is inserted into the database..TPIf the browser is not inserting a record, but the current record was changed by the user, the record is updated in the database with the current form's data (i.e. with the changes)..PPIf there is an error handling any of the above auto-edit actions, handleError() is called and no insert or update is performed..PPIf no error occurred, or auto-editing is not enabled, the data browser begins actively inserting a record into the database by performing the following actions:.TPThe default cursor is primed for insert using QSqlCursor::primeInsert()..TPThe primeInsert() signal is emitted..TPThe form is updated with the values in the default cursor's. edit buffer so that the user can fill in the values to be inserted..SH "bool QDataBrowser::insertCurrent ()\fC [virtual protected]\fR"Reads the fields from the default form into the default cursor and performs an insert on the default cursor. If there is no default form or no default cursor, nothing happens. If an error occurred during the insert into the database, handleError() is called and FALSE is returned. If the insert was successfull, the cursor is refreshed and relocated to the newly inserted record, the cursorChanged() signal is emitted, and TRUE is returned..PPSee also cursorChanged(), sqlCursor(), form() and handleError()..SH "bool QDataBrowser::isReadOnly () const"Returns TRUE if the browser is read-only; otherwise returns FALSE. See the "readOnly" property for details..SH "void QDataBrowser::last ()\fC [virtual slot]\fR"Moves the default cursor to the last record and refreshes the default form to display this record. If there is no default form or no default cursor, nothing happens. If the data browser successfully navigated to the last record, the default cursor is primed for update and the primeUpdate() signal is emitted..PPIf the browser is already positioned on the last record nothing happens..SH "void QDataBrowser::lastRecordAvailable ( bool available )\fC [signal]\fR"This signal is emitted whenever the position of the cursor changes. The \fIavailable\fR parameter indicates whether or not the last record in the default cursor is available..SH "void QDataBrowser::next ()\fC [virtual slot]\fR"Moves the default cursor to the next record and refreshes the default form to display this record. If there is no default form or no default cursor, nothing happens. If the data browser successfully navigated to the next record, the default cursor is primed for update and the primeUpdate() signal is emitted..PP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -