Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

Q3DataTable Class

TheQ3DataTable class provides a flexible SQL table widget that supports browsing and editing.More...

Header:#include <Q3DataTable>
Inherits:Q3Table

Public Types

enumRefresh { RefreshData, RefreshColumns, RefreshAll }

Properties

Public Functions

Q3DataTable(QWidget * parent = 0, const char * name = 0)
Q3DataTable(Q3SqlCursor * cursor, bool autoPopulate = false, QWidget * parent = 0, const char * name = 0)
~Q3DataTable()
virtual voidaddColumn(const QString & fieldName, const QString & label = QString(), int width = -1, const QIconSet & iconset = QIconSet())
boolautoDelete() const
boolautoEdit() const
boolconfirmCancels() const
boolconfirmDelete() const
boolconfirmEdits() const
boolconfirmInsert() const
boolconfirmUpdate() const
QSqlRecord *currentRecord() const
Qt::DateFormatdateFormat() const
QStringfalseText() const
QStringfilter() const
intindexOf(uint i) const
voidinstallEditorFactory(Q3SqlEditorFactory * f)
voidinstallPropertyMap(Q3SqlPropertyMap * m)
QStringnullText() const
voidrefresh(Refresh mode)
virtual voidsetAutoDelete(bool enable)
virtual voidsetAutoEdit(bool autoEdit)
virtual voidsetColumn(uint col, const QString & fieldName, const QString & label = QString(), int width = -1, const QIconSet & iconset = QIconSet())
virtual voidsetConfirmCancels(bool confirm)
virtual voidsetConfirmDelete(bool confirm)
virtual voidsetConfirmEdits(bool confirm)
virtual voidsetConfirmInsert(bool confirm)
virtual voidsetConfirmUpdate(bool confirm)
virtual voidsetDateFormat(const Qt::DateFormat f)
virtual voidsetFalseText(const QString & falseText)
virtual voidsetFilter(const QString & filter)
virtual voidsetNullText(const QString & nullText)
virtual voidsetSort(const QStringList & sort)
virtual voidsetSort(const QSqlIndex & sort)
virtual voidsetSqlCursor(Q3SqlCursor * cursor = 0, bool autoPopulate = false, bool autoDelete = false)
virtual voidsetTrueText(const QString & trueText)
QStringListsort() const
Q3SqlCursor *sqlCursor() const
QStringtrueText() const
QVariantvalue(int row, int col) const

Reimplemented Public Functions

virtual voidhideColumn(int col)
virtual intnumCols() const
virtual intnumRows() const
virtual voidremoveColumn(int col)
virtual voidselectRow(int row)
virtual voidsetNumCols(int r)
virtual voidsetNumRows(int r)
virtual voidshowColumn(int col)
virtual voidsortColumn(int col, bool ascending = true, bool wholeRows = false)
virtual QStringtext(int row, int col) const
  • 64 public functions inherited fromQ3Table
  • 49 public functions inherited fromQ3ScrollView
  • 4 public functions inherited fromQ3Frame
  • 14 public functions inherited fromQFrame
  • 220 public functions inherited fromQWidget
  • 29 public functions inherited fromQObject
  • 12 public functions inherited fromQPaintDevice

Public Slots

virtual voidadjustColumn(int col)
virtual voidfind(const QString & str, bool caseSensitive, bool backwards)
virtual voidrefresh()
virtual voidsetColumnStretchable(int col, bool s)
virtual voidsetColumnWidth(int col, int w)
virtual voidsortAscending(int col)
virtual voidsortDescending(int col)
virtual voidswapColumns(int col1, int col2, bool swapHeaders = false)

Signals

voidbeforeDelete(QSqlRecord * buf)
voidbeforeInsert(QSqlRecord * buf)
voidbeforeUpdate(QSqlRecord * buf)
voidcurrentChanged(QSqlRecord * record)
voidcursorChanged(QSql::Op mode)
voidprimeDelete(QSqlRecord * buf)
voidprimeInsert(QSqlRecord * buf)
voidprimeUpdate(QSqlRecord * buf)

Protected Functions

virtual boolbeginInsert()
virtual QWidget *beginUpdate(int row, int col, bool replace)
virtual QSql::ConfirmconfirmCancel(QSql::Op m)
virtual QSql::ConfirmconfirmEdit(QSql::Op m)
virtual booldeleteCurrent()
virtual intfieldAlignment(const QSqlField * field)
virtual voidhandleError(const QSqlError & e)
virtual boolinsertCurrent()
virtual voidpaintField(QPainter * p, const QSqlField * field, const QRect & cr, bool selected)
voidrepaintCell(int row, int col)
voidreset()
voidsetSize(Q3SqlCursor * sql)
virtual boolupdateCurrent()

Reimplemented Protected Functions

virtual voidactivateNextCell()
virtual voidclearCell(int row, int col)
virtual voidcolumnClicked(int col)
virtual voidcontentsContextMenuEvent(QContextMenuEvent * e)
virtual voidcontentsMousePressEvent(QMouseEvent * e)
virtual QWidget *createEditor(int row, int col, bool initFromCell) const
virtual voiddrawContents(QPainter * p, int cx, int cy, int cw, int ch)
virtual voidendEdit(int row, int col, bool accept, bool replace)
virtual booleventFilter(QObject * o, QEvent * e)
virtual Q3TableItem *item(int row, int col) const
virtual voidkeyPressEvent(QKeyEvent * e)
virtual voidpaintCell(QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg)
virtual voidresizeData(int len)
virtual voidresizeEvent(QResizeEvent * e)
virtual voidsetItem(int row, int col, Q3TableItem * item)
virtual voidsetPixmap(int row, int col, const QPixmap & pix)
virtual voidtakeItem(Q3TableItem * i)
  • 32 protected functions inherited fromQ3Table
  • 26 protected functions inherited fromQ3ScrollView
  • 5 protected functions inherited fromQ3Frame
  • 3 protected functions inherited fromQFrame
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 5 protected slots inherited fromQ3Table
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQ3DataTable class provides a flexible SQL table widget that supports browsing and editing.

Q3DataTable supports various functions for presenting and editing SQL data from aQ3SqlCursor in a table.

If you want a to present your data in a form useQDataBrowser, or for read-only forms, useQDataView instead.

When displaying data,Q3DataTable only retrieves data for visible rows. If the driver supports the 'query size' property theQ3DataTable will have the correct number of rows and the vertical scroll bar will accurately reflect the number of rows displayed in proportion to the number of rows in the dataset. If the driver does not support the 'query size' property, rows are dynamically fetched from the database on an as-needed basis with the scroll bar becoming more accurate as the user scrolls down through the records. This allows extremely large queries to be displayed as quickly as possible, with minimum memory usage.

Q3DataTable inheritsQ3Table's API and extends it with functions to sort and filter the data and sort columns. SeesetSqlCursor(),setFilter(),setSort(),setSorting(),sortColumn() andrefresh().

When displaying editable cursors, cell editing will be enabled. (For more information on editable cursors, seeQ3SqlCursor).Q3DataTable can be used to modify existing data and to add new records. When a user makes changes to a field in the table, the cursor's edit buffer is used. The table will not send changes in the edit buffer to the database until the user moves to a different record in the grid or presses Enter. Cell editing is initiated by pressing F2 (or right clicking and then clicking the appropriate popup menu item) and canceled by pressing Esc. If there is a problem updating or adding data, errors are handled automatically (seehandleError() to change this behavior). Note that ifautoEdit() is false navigating to another record will cancel the insert or update.

The user can be asked to confirm all edits withsetConfirmEdits(). For more precise control usesetConfirmInsert(),setConfirmUpdate(),setConfirmDelete() andsetConfirmCancels(). UsesetAutoEdit() to control the behavior of the table when the user edits a record and then navigates. (Note thatsetAutoDelete() is unrelated; it is used to set whether theQ3SqlCursor is deleted when the table is deleted.)

Since the data table can perform edits, it must be able to uniquely identify every record so that edits are correctly applied. Because of this the underlying cursor must have a valid primary index to ensure that a unique record is inserted, updated or deleted within the database otherwise the database may be changed to an inconsistent state.

Q3DataTable creates editors using the defaultQ3SqlEditorFactory. Different editor factories can be used by callinginstallEditorFactory(). A property map is used to map between the cell's value and the editor. You can use your own property map withinstallPropertyMap().

The contents of a cell is available as aQString withtext() or as aQVariant withvalue(). The current record is returned bycurrentRecord(). Use thefind() function to search for a string in the table.

Editing actions can be applied programmatically. For example, theinsertCurrent() function reads the fields from the current record into the cursor and performs the insert. TheupdateCurrent() anddeleteCurrent() functions perform similarly to update and delete the current record respectively.

Columns in the table can be created automatically based on the cursor (seesetSqlCursor()). Columns can be manipulated manually usingaddColumn(),removeColumn() andsetColumn().

The table automatically copies many of the properties of the cursor to format the display of data within cells (alignment, visibility, etc.). The cursor can be changed withsetSqlCursor(). The filter (seesetFilter()) and sort defined within the table are used instead of the filter and sort set on the cursor. For sorting options seesetSort(),sortColumn(),sortAscending() andsortDescending(). Note that sorting operations will not behave as expected if you are using aQSqlSelectCursor because it uses user-defined SQL queries to obtain data.

The text used to represent NULL, true and false values can be changed withsetNullText(),setTrueText() andsetFalseText() respectively. You can change the appearance of cells by reimplementingpaintField().

Whenever a new row is selected in the table thecurrentChanged() signal is emitted. TheprimeInsert() signal is emitted when an insert is initiated. TheprimeUpdate() andprimeDelete() signals are emitted when update and deletion are initiated respectively. Just before the database is updated a signal is emitted;beforeInsert(),beforeUpdate() orbeforeDelete() as appropriate.

Member Type Documentation

enum Q3DataTable::Refresh

This enum describes the refresh options.

ConstantValueDescription
Q3DataTable::RefreshData1refresh the data, i.e. read it from the database
Q3DataTable::RefreshColumns2refresh the list of fields, e.g. the column headings
Q3DataTable::RefreshAll3refresh both the data and the list of fields

Property Documentation

autoEdit :bool

This property holds whether the data table automatically applies edits.

The default value for this property is true. When the user begins an insert or update in the table there are two possible outcomes when they navigate to another record:

  1. the insert or update is is performed -- this occurs if autoEdit is true
  2. the insert or update is abandoned -- this occurs if autoEdit is false

Access functions:

boolautoEdit() const
virtual voidsetAutoEdit(bool autoEdit)

confirmCancels :bool

This property holds whether the data table confirms cancel operations.

If theconfirmCancel property is true, all cancels must be confirmed by the user through a message box (this behavior can be changed by overriding theconfirmCancel() function), otherwise all cancels occur immediately. The default is false.

Access functions:

boolconfirmCancels() const
virtual voidsetConfirmCancels(bool confirm)

See alsoconfirmEdits() andconfirmCancel().

confirmDelete :bool

This property holds whether the data table confirms delete operations.

If the confirmDelete property is true, all deletions must be confirmed by the user through a message box (this behavior can be changed by overriding theconfirmEdit() function), otherwise all delete operations occur immediately.

Access functions:

boolconfirmDelete() const
virtual voidsetConfirmDelete(bool confirm)

See alsoconfirmCancels(),confirmEdits(),confirmUpdate(), andconfirmInsert().

confirmEdits :bool

This property holds whether the data table confirms edit operations.

If the confirmEdits property is true, the data table confirms all edit operations (inserts, updates and deletes). Finer control of edit confirmation can be achieved usingconfirmCancels,confirmInsert,confirmUpdate andconfirmDelete.

Access functions:

boolconfirmEdits() const
virtual voidsetConfirmEdits(bool confirm)

See alsoconfirmCancels(),confirmInsert(),confirmUpdate(), andconfirmDelete().

confirmInsert :bool

This property holds whether the data table confirms insert operations.

If the confirmInsert property is true, all insertions must be confirmed by the user through a message box (this behavior can be changed by overriding theconfirmEdit() function), otherwise all insert operations occur immediately.

Access functions:

boolconfirmInsert() const
virtual voidsetConfirmInsert(bool confirm)

See alsoconfirmCancels(),confirmEdits(),confirmUpdate(), andconfirmDelete().

confirmUpdate :bool

This property holds whether the data table confirms update operations.

If the confirmUpdate property is true, all updates must be confirmed by the user through a message box (this behavior can be changed by overriding theconfirmEdit() function), otherwise all update operations occur immediately.

Access functions:

boolconfirmUpdate() const
virtual voidsetConfirmUpdate(bool confirm)

See alsoconfirmCancels(),confirmEdits(),confirmInsert(), andconfirmDelete().

dateFormat :Qt::DateFormat

This property holds the format used for displaying date/time values.

The dateFormat property is used for displaying date/time values in the table. The default value isQt::LocalDate.

Access functions:

Qt::DateFormatdateFormat() const
virtual voidsetDateFormat(const Qt::DateFormat f)

falseText :QString

This property holds the text used to represent false values.

The falseText property will be used to represent NULL values in the table. The default value is "False".

Access functions:

QStringfalseText() const
virtual voidsetFalseText(const QString & falseText)

filter :QString

This property holds the data filter for the data table.

The filter applies to the data shown in the table. To view data with a new filter, userefresh(). A filter string is an SQL WHERE clause without the WHERE keyword.

There is no default filter.

Access functions:

QStringfilter() const
virtual voidsetFilter(const QString & filter)

See alsosort().

nullText :QString

This property holds the text used to represent NULL values.

The nullText property will be used to represent NULL values in the table. The default value is provided by the cursor's driver.

Access functions:

QStringnullText() const
virtual voidsetNullText(const QString & nullText)

numCols :int

This property holds the number of columns in the table.

Access functions:

virtual intnumCols() const
virtual voidsetNumCols(int r)

numRows :int

This property holds the number of rows in the table.

Access functions:

virtual intnumRows() const
virtual voidsetNumRows(int r)

sort :QStringList

This property holds the data table's sort.

The table's sort affects the order in which data records are displayed in the table. To apply a sort, userefresh().

When examining the sort property, a string list is returned with each item having the form 'fieldname order' (e.g., 'id ASC', 'surname DESC').

There is no default sort.

Note that if you want to iterate over the sort list, you should iterate over a copy, e.g.

QStringList list= myDataTable.sort();QStringList::Iterator it= list.begin();while( it!= list.end() ) {    myProcessing(*it );++it;}

Access functions:

QStringListsort() const
virtual voidsetSort(const QStringList & sort)
virtual voidsetSort(const QSqlIndex & sort)

See alsofilter() andrefresh().

trueText :QString

This property holds the text used to represent true values.

The trueText property will be used to represent NULL values in the table. The default value is "True".

Access functions:

QStringtrueText() const
virtual voidsetTrueText(const QString & trueText)

Member Function Documentation

Q3DataTable::Q3DataTable(QWidget * parent = 0, constchar * name = 0)

Constructs a data table which is a child ofparent, called namename.

Q3DataTable::Q3DataTable(Q3SqlCursor * cursor,bool autoPopulate = false,QWidget * parent = 0, constchar * name = 0)

Constructs a data table which is a child ofparent, called namename using the cursorcursor.

IfautoPopulate is true (the default is false), columns are automatically created based upon the fields in thecursor record. Note thatautoPopulate only governs the creation of columns; to load the cursor's data into the table userefresh().

If thecursor is read-only, the table also becomes read-only. In addition, the table adopts the cursor's driver's definition for representing NULL values as strings.

Q3DataTable::~Q3DataTable()

Destroys the object and frees any allocated resources.

[virtual protected]void Q3DataTable::activateNextCell()

Reimplemented fromQ3Table::activateNextCell().

[virtual]void Q3DataTable::addColumn(constQString & fieldName, constQString & label = QString(),int width = -1, constQIconSet & iconset = QIconSet())

Adds the next column to be displayed using the fieldfieldName, column labellabel, widthwidth and iconseticonset.

Iflabel is specified, it is used as the column's header label, otherwise the field's display label is used whensetSqlCursor() is called. Theiconset is used to set the icon used by the column header; by default there is no icon.

See alsosetSqlCursor() andrefresh().

[virtual slot]void Q3DataTable::adjustColumn(int col)

Reimplemented fromQ3Table::adjustColumn().

Resizes columncol so that the column width is wide enough to display the widest item the column contains (including the column label). If the table'sQ3SqlCursor is not currently active, the cursor will be refreshed before the column width is calculated. Be aware that this function may be slow on tables that contain large result sets.

bool Q3DataTable::autoDelete() const

Returns true if the table will automatically delete the cursor specified bysetSqlCursor(); otherwise returns false.

See alsosetAutoDelete().

[signal]void Q3DataTable::beforeDelete(QSqlRecord * buf)

This signal is emitted just before the currently selected record is deleted from the database. Thebuf parameter points to the edit buffer being deleted. Connect to this signal to, for example, copy some of the fields for later use.

[signal]void Q3DataTable::beforeInsert(QSqlRecord * buf)

This signal is emitted just before the cursor's edit buffer is inserted into the database. Thebuf parameter points to the edit buffer being inserted. Connect to this signal to, for example, populate a key field with a unique sequence number.

[signal]void Q3DataTable::beforeUpdate(QSqlRecord * buf)

This signal is emitted just before the cursor's edit buffer is updated in the database. Thebuf parameter points to the edit buffer being updated. Connect to this signal when you want to transform the user's data behind-the-scenes.

[virtual protected]bool Q3DataTable::beginInsert()

Protected virtual function called when editing is about to begin on a new record. If the table is read-only, or if there's no cursor or the cursor does not allow inserts, nothing happens and false is returned. Otherwise returns true.

Editing takes place using the cursor's edit buffer(seeQ3SqlCursor::editBuffer()).

When editing begins, a new row is created in the table marked with an asterisk '*' in the row's vertical header column, i.e. at the left of the row.

[virtual protected]QWidget * Q3DataTable::beginUpdate(int row,int col,bool replace)

Protected virtual function called when editing is about to begin on an existing row. If the table is read-only, or if there's no cursor, nothing happens.

Editing takes place using the cursor's edit buffer (seeQ3SqlCursor::editBuffer()).

row andcol refer to the row and column in theQ3DataTable.

(replace is provided for reimplementors and reflects the API ofQ3Table::beginEdit().)

[virtual protected]void Q3DataTable::clearCell(int row,int col)

Reimplemented fromQ3Table::clearCell().

[virtual protected]void Q3DataTable::columnClicked(int col)

Reimplemented fromQ3Table::columnClicked().

[virtual protected]QSql::Confirm Q3DataTable::confirmCancel(QSql::Op m)

Protected virtual function which returns a confirmation for canceling an edit mode ofm. Derived classes can reimplement this function to provide their own cancel dialog. The default implementation uses a message box which prompts the user to confirm the cancel.

[virtual protected]QSql::Confirm Q3DataTable::confirmEdit(QSql::Op m)

Protected virtual function which returns a confirmation for an edit of modem. Derived classes can reimplement this function to provide their own confirmation dialog. The default implementation uses a message box which prompts the user to confirm the edit action.

[virtual protected]void Q3DataTable::contentsContextMenuEvent(QContextMenuEvent * e)

Reimplemented fromQ3ScrollView::contentsContextMenuEvent().

[virtual protected]void Q3DataTable::contentsMousePressEvent(QMouseEvent * e)

Reimplemented fromQ3ScrollView::contentsMousePressEvent().

[virtual protected]QWidget * Q3DataTable::createEditor(int row,int col,bool initFromCell) const

Reimplemented fromQ3Table::createEditor().

For an editable table, creates an editor suitable for the field in columncol. The editor is created using the default editor factory, unless a different editor factory was installed withinstallEditorFactory(). The editor is primed with the value of the field incol using a property map. The property map used is the default property map, unless a new property map was installed with installPropertMap(). IfinitFromCell is true then the editor is primed with the value in theQ3DataTable cell.

[signal]void Q3DataTable::currentChanged(QSqlRecord * record)

This signal is emitted whenever a new row is selected in the table. Therecord parameter points to the contents of the newly selected record.

QSqlRecord * Q3DataTable::currentRecord() const

Returns the currently selected record, or 0 if there is no current selection. The table owns the pointer, so donot delete it or otherwise modify it or the cursor it points to.

[signal]void Q3DataTable::cursorChanged(QSql::Op mode)

This signal is emitted whenever the cursor record was changed due to an edit. Themode parameter is the type of edit that just took place.

[virtual protected]bool Q3DataTable::deleteCurrent()

For an editable table, issues a delete on the current cursor's primary index using the values of the currently selected row. If there is no current cursor or there is no current selection, nothing happens. IfconfirmEdits() orconfirmDelete() is true,confirmEdit() is called to confirm the delete. Returns true if the delete succeeded; otherwise false.

The underlying cursor must have a valid primary index to ensure that a unique record is deleted within the database otherwise the database may be changed to an inconsistent state.

[virtual protected]void Q3DataTable::drawContents(QPainter * p,int cx,int cy,int cw,int ch)

Reimplemented fromQ3ScrollView::drawContents().

[virtual protected]void Q3DataTable::endEdit(int row,int col,bool accept,bool replace)

Reimplemented fromQ3Table::endEdit().

[virtual protected]bool Q3DataTable::eventFilter(QObject * o,QEvent * e)

Reimplemented fromQObject::eventFilter().

[virtual protected]int Q3DataTable::fieldAlignment(constQSqlField * field)

Returns the alignment forfield.

[virtual slot]void Q3DataTable::find(constQString & str,bool caseSensitive,bool backwards)

Searches the current cursor for a cell containing the stringstr starting at the current cell and working forwards (or backwards ifbackwards is true). If the string is found, the cell containing the string is set as the current cell. IfcaseSensitive is false the case ofstr will be ignored.

The search will wrap, i.e. if the first (or if backwards is true, last) cell is reached without findingstr the search will continue until it reaches the starting cell. Ifstr is not found the search will fail and the current cell will remain unchanged.

[virtual protected]void Q3DataTable::handleError(constQSqlError & e)

Protected virtual function which is called when an errore has occurred on the currentcursor(). The default implementation displays a warning message to the user with information about the error.

[virtual]void Q3DataTable::hideColumn(int col)

Reimplemented fromQ3Table::hideColumn().

int Q3DataTable::indexOf(uint i) const

Returns the index of the field within the current SQL query that is displayed in columni.

[virtual protected]bool Q3DataTable::insertCurrent()

For an editable table, issues an insert on the current cursor using the values in the cursor's edit buffer. If there is no current cursor or there is no current "insert" row, nothing happens. IfconfirmEdits() orconfirmInsert() is true,confirmEdit() is called to confirm the insert. Returns true if the insert succeeded; otherwise returns false.

The underlying cursor must have a valid primary index to ensure that a unique record is inserted within the database otherwise the database may be changed to an inconsistent state.

void Q3DataTable::installEditorFactory(Q3SqlEditorFactory * f)

Installs a new SQL editor factoryf. This enables the user to create and instantiate their own editors for use in cell editing. Note thatQ3DataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installEditorFactory() is called again.

See alsoQ3SqlEditorFactory.

void Q3DataTable::installPropertyMap(Q3SqlPropertyMap * m)

Installs a new property mapm. This enables the user to create and instantiate their own property maps for use in cell editing. Note thatQ3DataTable takes ownership of this pointer, and will delete it when it is no longer needed or when installPropertMap() is called again.

See alsoQ3SqlPropertyMap.

[virtual protected]Q3TableItem * Q3DataTable::item(int row,int col) const

Reimplemented fromQ3Table::item().

See alsosetItem().

[virtual protected]void Q3DataTable::keyPressEvent(QKeyEvent * e)

Reimplemented fromQWidget::keyPressEvent().

[virtual protected]void Q3DataTable::paintCell(QPainter * p,int row,int col, constQRect & cr,bool selected, constQColorGroup & cg)

Reimplemented fromQ3Table::paintCell().

This function renders the cell atrow,col with the value of the corresponding cursor field on the painterp. Depending on the table's current edit mode,paintField() is called for the appropriate cursor field.cr describes the cell coordinates in the content coordinate system. Ifselected is true the cell has been selected and would normally be rendered differently than an unselected cell.

[virtual protected]void Q3DataTable::paintField(QPainter * p, constQSqlField * field, constQRect & cr,bool selected)

Paints thefield on the painterp. The painter has already been translated to the appropriate cell's origin where thefield is to be rendered.cr describes the cell coordinates in the content coordinate system. Theselected parameter is ignored.

If you want to draw custom field content you must reimplement paintField() to do the custom drawing. The default implementation renders thefield value as text. If the field is NULL,nullText() is displayed in the cell. If the field is Boolean,trueText() orfalseText() is displayed as appropriate.

[signal]void Q3DataTable::primeDelete(QSqlRecord * buf)

This signal is emitted after the cursor is primed for delete by the table, when a delete action is beginning on the table. Thebuf parameter points to the edit buffer being deleted. Connect to this signal in order to, for example, record auditing information on deletions.

[signal]void Q3DataTable::primeInsert(QSqlRecord * buf)

This signal is emitted after the cursor is primed for insert by the table, when an insert action is beginning on the table. Thebuf parameter points to the edit buffer being inserted. Connect to this signal in order to, for example, prime the record buffer with default data values.

[signal]void Q3DataTable::primeUpdate(QSqlRecord * buf)

This signal is emitted after the cursor is primed for update by the table, when an update action is beginning on the table. Thebuf parameter points to the edit buffer being updated. Connect to this signal in order to, for example, provide some visual feedback that the user is in 'edit mode'.

void Q3DataTable::refresh(Refresh mode)

Refreshes the table. If there is no currently defined cursor (seesetSqlCursor()), nothing happens. Themode parameter determines which type of refresh will take place.

See alsoRefresh,setSqlCursor(), andaddColumn().

[virtual slot]void Q3DataTable::refresh()

Refreshes the table. The cursor is refreshed using the current filter, the current sort, and the currently defined columns. Equivalent to calling refresh(Q3DataTable::RefreshData ).

[virtual]void Q3DataTable::removeColumn(int col)

Reimplemented fromQ3Table::removeColumn().

Removes columncol from the list of columns to be displayed. Ifcol does not exist, nothing happens.

See alsoQSqlField.

[protected]void Q3DataTable::repaintCell(int row,int col)

Repaints the cell atrow,col.

[protected]void Q3DataTable::reset()

Resets the table so that it displays no data.

See alsosetSqlCursor().

[virtual protected]void Q3DataTable::resizeData(int len)

Reimplemented fromQ3Table::resizeData().

[virtual protected]void Q3DataTable::resizeEvent(QResizeEvent * e)

Reimplemented fromQWidget::resizeEvent().

[virtual]void Q3DataTable::selectRow(int row)

Reimplemented fromQ3Table::selectRow().

[virtual]void Q3DataTable::setAutoDelete(bool enable)

Sets the cursor auto-delete flag toenable. Ifenable is true, the table will automatically delete the cursor specified bysetSqlCursor(). Ifenable is false (the default), the cursor will not be deleted.

See alsoautoDelete().

[virtual]void Q3DataTable::setColumn(uint col, constQString & fieldName, constQString & label = QString(),int width = -1, constQIconSet & iconset = QIconSet())

Sets thecol column to display using the fieldfieldName, column labellabel, widthwidth and iconseticonset.

Iflabel is specified, it is used as the column's header label, otherwise the field's display label is used whensetSqlCursor() is called. Theiconset is used to set the icon used by the column header; by default there is no icon.

See alsosetSqlCursor() andrefresh().

[virtual slot]void Q3DataTable::setColumnStretchable(int col,bool s)

Reimplemented fromQ3Table::setColumnStretchable().

[virtual slot]void Q3DataTable::setColumnWidth(int col,int w)

Reimplemented fromQ3Table::setColumnWidth().

Sets the columncol to the widthw. Note that unlikeQ3Table theQ3DataTable is not immediately redrawn, you must call refresh(Q3DataTable::RefreshColumns) yourself.

See alsorefresh().

[virtual protected]void Q3DataTable::setItem(int row,int col,Q3TableItem * item)

Reimplemented fromQ3Table::setItem().

See alsoitem().

[virtual]void Q3DataTable::setNumCols(int r)

Reimplemented fromQ3Table::setNumCols().

The number of columns in the table will be determined automatically (seeaddColumn()), so normally this function should never be called. It is included for completeness.

See alsonumCols().

[virtual]void Q3DataTable::setNumRows(int r)

Reimplemented fromQ3Table::setNumRows().

The number of rows in the table will be determined by the cursor (seesetSqlCursor()), so normally this function should never be called. It is included for completeness.

See alsonumRows().

[virtual protected]void Q3DataTable::setPixmap(int row,int col, constQPixmap & pix)

Reimplemented fromQ3Table::setPixmap().

[protected]void Q3DataTable::setSize(Q3SqlCursor * sql)

If the cursor'ssql driver supports query sizes, the number of rows in the table is set to the size of the query. Otherwise, the table dynamically resizes itself as it is scrolled. Ifsql is not active, it is made active by issuing a select() on the cursor using thesql cursor's current filter and current sort.

[virtual]void Q3DataTable::setSqlCursor(Q3SqlCursor * cursor = 0,bool autoPopulate = false,bool autoDelete = false)

Setscursor as the data source for the table. To force the display of the data fromcursor, userefresh(). IfautoPopulate is true, columns are automatically created based upon the fields in thecursor record. IfautoDelete is true (the default is false), the table will take ownership of thecursor and delete it when appropriate. If thecursor is read-only, the table becomes read-only. The table adopts the cursor's driver's definition for representing NULL values as strings.

See alsosqlCursor(),refresh(),setReadOnly(),setAutoDelete(), andQSqlDriver::nullText().

[virtual]void Q3DataTable::showColumn(int col)

Reimplemented fromQ3Table::showColumn().

[virtual slot]void Q3DataTable::sortAscending(int col)

Sorts columncol in ascending order.

See alsosetSorting().

[virtual]void Q3DataTable::sortColumn(int col,bool ascending = true,bool wholeRows = false)

Reimplemented fromQ3Table::sortColumn().

Sorts columncol in ascending order ifascending is true (the default); otherwise sorts in descending order.

ThewholeRows parameter is ignored;Q3DataTable always sorts whole rows by the specified column.

[virtual slot]void Q3DataTable::sortDescending(int col)

Sorts columncol in descending order.

See alsosetSorting().

Q3SqlCursor * Q3DataTable::sqlCursor() const

Returns the cursor used by the data table.

See alsosetSqlCursor().

[virtual slot]void Q3DataTable::swapColumns(int col1,int col2,bool swapHeaders = false)

Reimplemented fromQ3Table::swapColumns().

[virtual protected]void Q3DataTable::takeItem(Q3TableItem * i)

Reimplemented fromQ3Table::takeItem().

[virtual]QString Q3DataTable::text(int row,int col) const

Reimplemented fromQ3Table::text().

Returns the text in cellrow,col, or an empty string if the cell is empty. If the cell's value is NULL thennullText() will be returned. If the cell does not exist then an empty string is returned.

[virtual protected]bool Q3DataTable::updateCurrent()

For an editable table, issues an update using the cursor's edit buffer. If there is no current cursor or there is no current selection, nothing happens. IfconfirmEdits() orconfirmUpdate() is true,confirmEdit() is called to confirm the update. Returns true if the update succeeded; otherwise returns false.

The underlying cursor must have a valid primary index to ensure that a unique record is updated within the database otherwise the database may be changed to an inconsistent state.

QVariant Q3DataTable::value(int row,int col) const

Returns the value in cellrow,col, or an invalid value if the cell does not exist or has no value.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp