QDataTable(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

QDataTable(3qt) πŸ’–βœ¨

okay bestie, welcome to the QDataTable(3qt) page β€” it's giving flexible SQL table widget energy, and it supports browsing and editing, no cap. πŸ’…


πŸ’– NAME πŸ’–

QDataTable - Flexible SQL table widget that supports browsing and editing πŸ¦‹

✨ SYNOPSIS ✨

#include <qdatatable.h>

Inherits QTable. Periodt.

🌸 Public Members 🌸

  • QDataTable ( QWidget * parent = 0, const char * name = 0 )
  • QDataTable ( QSqlCursor * cursor, bool autoPopulate = FALSE, QWidget * parent = 0, const char * name = 0 )
  • ~QDataTable ()
  • virtual void addColumn ( const QString & fieldName, const QString & label = QString::null, int width = -1, const QIconSet & iconset = QIconSet ( ) )
  • virtual void removeColumn ( uint col )
  • virtual void setColumn ( uint col, const QString & fieldName, const QString & label = QString::null, int width = -1, const QIconSet & iconset = QIconSet ( ) )
  • QString nullText () const
  • QString trueText () const
  • QString falseText () const
  • DateFormat dateFormat () const
  • bool confirmEdits () const
  • bool confirmInsert () const
  • bool confirmUpdate () const
  • bool confirmDelete () const
  • bool confirmCancels () const
  • bool autoDelete () const
  • bool autoEdit () const
  • QString filter () const
  • QStringList sort () const
  • virtual void setSqlCursor ( QSqlCursor * cursor = 0, bool autoPopulate = FALSE, bool autoDelete = FALSE )
  • QSqlCursor * sqlCursor () const
  • virtual void setNullText ( const QString & nullText )
  • virtual void setTrueText ( const QString & trueText )
  • virtual void setFalseText ( const QString & falseText )
  • virtual void setDateFormat ( const DateFormat f )
  • virtual void setConfirmEdits ( bool confirm )
  • virtual void setConfirmInsert ( bool confirm )
  • virtual void setConfirmUpdate ( bool confirm )
  • virtual void setConfirmDelete ( bool confirm )
  • virtual void setConfirmCancels ( bool confirm )
  • virtual void setAutoDelete ( bool enable )
  • virtual void setAutoEdit ( bool autoEdit )
  • virtual void setFilter ( const QString & filter )
  • virtual void setSort ( const QStringList & sort )
  • virtual void setSort ( const QSqlIndex & sort )
  • enum Refresh { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 }
  • void refresh ( Refresh mode )
  • virtual void sortColumn ( int col, bool ascending = TRUE, bool wholeRows = FALSE )
  • virtual QString text ( int row, int col ) const
  • QVariant value ( int row, int col ) const
  • QSqlRecord * currentRecord () const
  • void installEditorFactory ( QSqlEditorFactory * f )
  • void installPropertyMap ( QSqlPropertyMap * m )
  • virtual int numCols () const
  • virtual int numRows () const

πŸŽ€ Public Slots πŸŽ€

  • virtual void find ( const QString & str, bool caseSensitive, bool backwards )
  • virtual void sortAscending ( int col )
  • virtual void sortDescending ( int col )
  • virtual void refresh ()
  • virtual void setColumnWidth ( int col, int w )
  • virtual void adjustColumn ( int col )

πŸ“‘ Signals πŸ“‘

  • void currentChanged ( QSqlRecord * record )
  • void primeInsert ( QSqlRecord * buf )
  • void primeUpdate ( QSqlRecord * buf )
  • void primeDelete ( QSqlRecord * buf )
  • void beforeInsert ( QSqlRecord * buf )
  • void beforeUpdate ( QSqlRecord * buf )
  • void beforeDelete ( QSqlRecord * buf )
  • void cursorChanged ( QSql::Op mode )

🌈 Properties 🌈

  • bool autoEdit β€” whether the data table automatically applies edits
  • bool confirmCancels β€” whether the data table confirms cancel operations
  • bool confirmDelete β€” whether the data table confirms delete operations
  • bool confirmEdits β€” whether the data table confirms edit operations
  • bool confirmInsert β€” whether the data table confirms insert operations
  • bool confirmUpdate β€” whether the data table confirms update operations
  • DateFormat dateFormat β€” the format used for displaying date/time values
  • QString falseText β€” the text used to represent false values
  • QString filter β€” the data filter for the data table
  • QString nullText β€” the text used to represent NULL values
  • int numCols β€” the number of columns in the table (read only)
  • int numRows β€” the number of rows in the table (read only)
  • QStringList sort β€” the data table's sort
  • QString trueText β€” the text used to represent true values

πŸ”’ Protected Members πŸ”’

  • virtual bool insertCurrent ()
  • virtual bool updateCurrent ()
  • virtual bool deleteCurrent ()
  • virtual QSql::Confirm confirmEdit ( QSql::Op m )
  • virtual QSql::Confirm confirmCancel ( QSql::Op m )
  • virtual void handleError ( const QSqlError & e )
  • virtual bool beginInsert ()
  • virtual QWidget * beginUpdate ( int row, int col, bool replace )
  • int indexOf ( uint i ) const
  • void reset ()
  • void setSize ( QSqlCursor * sql )
  • virtual void paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected )
  • virtual int fieldAlignment ( const QSqlField * field )

πŸ’… DESCRIPTION πŸ’…

The QDataTable class provides a flexible SQL table widget that supports browsing and editing. It's literally the main character of SQL table widgets. πŸ’–

QDataTable supports various functions for presenting and editing SQL data from a QSqlCursor in a table. Slay.

If you want a to present your data in a form use QDataBrowser, or for read-only forms, QDataView. Noted bestie. πŸŽ€

When displaying data, QDataTable only retrieves data for visible rows. If the driver supports the 'query size' property the QDataTable will have the correct number of rows and the vertical scrollbar 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 scrollbar 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. Efficiency queen. πŸ‘‘

QDataTable inherits QTable's API and extends it with functions to sort and filter the data and sort columns. See setSqlCursor(), setFilter(), setSort(), setSorting(), sortColumn() and refresh(). iykyk. ✨

When displaying editable cursors, cell editing will be enabled. (For more information on editable cursors, see QSqlCursor). QDataTable 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 (see handleError() to change this behavior). Note that if autoEdit() is FALSE navigating to another record will cancel the insert or update. Big yikes if you're not paying attention. 😭

The 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 table when the user edits a record and then navigates. (Note that setAutoDelete() is unrelated; it is used to set whether the QSqlCursor is deleted when the table is deleted.) Don't mix them up, bestie. πŸ’…

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.

This is not a drill: no valid primary index = potential inconsistent database. Be careful. 🚨

QDataTable creates editors using the default QSqlEditorFactory. Different editor factories can be used by calling installEditorFactory(). A property map is used to map between the cell's value and the editor. You can use your own property map with installPropertyMap(). Customization? We love to see it. πŸ¦‹

The contents of a cell is available as a QString with text() or as a QVariant with value(). The current record is returned by currentRecord(). Use the find() function to search for a string in the table. Search queen. πŸ”

Editing actions can be applied programatically. For example, the insertCurrent() function reads the fields from the current record into the cursor and performs the insert. The updateCurrent() and deleteCurrent() functions perform similarly to update and delete the current record respectively. Programmatic slay. ✨

Columns in the table can be created automatically based on the cursor (see setSqlCursor()). Columns can be manipulated manually using addColumn(), removeColumn() and setColumn(). Build-a-column workshop. πŸŽ€

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 with setSqlCursor(). The filter (see setFilter()) and sort defined within the table are used instead of the filter and sort set on the cursor. For sorting options see setSort(), sortColumn(), sortAscending() and sortDescending(). Note that sorting operations will not behave as expected if you are using a QSqlSelectCursor because it uses user-defined SQL queries to obtain data. So don't be surprised, okay? 😭

The text used to represent NULL, TRUE and FALSE values can be changed with setNullText(), setTrueText() and setFalseText() respectively. You can change the appearance of cells by reimplementing paintField(). Make it pretty. πŸ’…

Whenever a new row is selected in the table the currentChanged() signal is emitted. The primeInsert() signal is emitted when an insert is initiated. The primeUpdate() and primeDelete() signals are emitted when update and deletion are initiated respectively. Just before the database is updated a signal is emitted; beforeInsert(), beforeUpdate() or beforeDelete() as appropriate. Signal tea. πŸ“‘

See also Database Classes. πŸ‘‘

🧚 Member Type Documentation 🧚

QDataTable::Refresh

This enum describes the refresh options.

  • QDataTable::RefreshData β€” refresh the data, i.e. read it from the database
  • QDataTable::RefreshColumns β€” refresh the list of fields, e.g. the column headings
  • QDataTable::RefreshAll β€” refresh both the data and the list of fields

πŸ‘‘ MEMBER FUNCTION DOCUMENTATION πŸ‘‘

QDataTable::QDataTable ( QWidget * parent = 0, const char * name = 0 )

Constructs a data table which is a child of parent, called name name β€” yes, the manpage really says that, and we're keeping the typo energy alive 😭.

QDataTable::QDataTable ( QSqlCursor * cursor, bool autoPopulate = FALSE, QWidget * parent = 0, const char * name = 0 )

Constructs a data table which is a child of parent, called name name using the cursor cursor.

If autoPopulate is TRUE (the default is FALSE), columns are automatically created based upon the fields in the cursor record. Note that autoPopulate only governs the creation of columns; to load the cursor's data into the table use refresh().

If the cursor 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.

QDataTable::~QDataTable ()

Destroys the object and frees any allocated resources.

void QDataTable::addColumn ( const QString & fieldName, const QString & label = QString::null, int width = -1, const QIconSet & iconset = QIconSet ( ) ) [virtual]

okay so this adds the next column to be displayed πŸ’… and you're specifying the field fieldName, the column label label, the width width, and the iconset iconset.

If you pass a label, it becomes the column's header label. If you don't, the field's display label gets used instead β€” but only when setSqlCursor() is called. The iconset sets the icon on the column header, and by default there is literally no icon. πŸŽ€

See also setSqlCursor() and refresh().

Examples:


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

Resizes column col so its width is wide enough to fit the widest item the column holds β€” and yes, the column label counts too. 🫢 If the table's QSqlCursor isn't currently active, the cursor gets refreshed first, and then the column width is calculated.

bestie be warned: this function may be slow on tables with big result sets. 😭

Reimplemented from QTable.


bool QDataTable::autoDelete () const

Returns TRUE if the table is gonna automatically delete the cursor you set with setSqlCursor(); otherwise FALSE. ✨


bool QDataTable::autoEdit () const

Returns TRUE if the data table automatically applies edits; otherwise FALSE. See the "autoEdit" property for the deets. πŸ’–


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

This signal fires just before the currently selected record gets deleted from the database. The buf parameter points at the edit buffer being deleted. Connect to this signal if you wanna, like, copy some of the fields for later use. πŸ‘‘


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

This signal fires just before the cursor's edit buffer is inserted into the database. The buf parameter points at the edit buffer being inserted. Connect to this if you wanna, for example, populate a key field with a unique sequence number. πŸ”₯


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

This signal fires just before the cursor's edit buffer is updated in the database. The buf parameter points at the edit buffer being updated. Connect to this when you want to transform the user's data behind-the-scenes. πŸ•΅οΈβ€β™€οΈ


bool QDataTable::beginInsert () [virtual protected]

Protected virtual function, called when editing is about to begin on a brand new record. If the table is read-only, or if there's no cursor, or the cursor doesn't allow inserts β€” nothing happens. sorry bestie, nothing. πŸ™ˆ

Editing happens using the cursor's edit buffer (see QSqlCursor::editBuffer()).

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


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

Protected virtual function, called when editing is about to begin on a row that already exists. If the table is read-only, or if there's no cursor β€” nothing happens.

Editing happens using the cursor's edit buffer (see QSqlCursor::editBuffer()).

row and col refer to the row and column in the QDataTable.

(replace is provided for reimplementors and reflects the API of QTable::beginEdit().) πŸ’œ


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

Protected virtual function which returns a confirmation for cancelling an edit mode of m. 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. πŸŽ€


bool QDataTable::confirmCancels () const

Returns TRUE if the data table confirms cancel operations; otherwise FALSE. See the "confirmCancels" property for details.


bool QDataTable::confirmDelete () const

Returns TRUE if the data table confirms delete operations; otherwise FALSE. See the "confirmDelete" property for details.


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

Protected virtual function which returns a confirmation for an edit of mode m. 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. πŸ’…


bool QDataTable::confirmEdits () const

Returns TRUE if the data table confirms edit operations; otherwise FALSE. See the "confirmEdits" property for details.


bool QDataTable::confirmInsert () const

Returns TRUE if the data table confirms insert operations; otherwise FALSE. See the "confirmInsert" property for details.


bool QDataTable::confirmUpdate () const

Returns TRUE if the data table confirms update operations; otherwise FALSE. See the "confirmUpdate" property for details.


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

This signal is emitted whenever a new row is selected in the table. The record parameter points at the contents of the newly selected record. ✨


QSqlRecord * QDataTable::currentRecord () const

Returns the currently selected record, or 0 if there's no current selection.

bestie. the table owns that pointer. do NOT delete it, and don't otherwise modify it or the cursor it points to. πŸ™…β€β™€οΈ

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

This signal is emitted whenever the cursor record was changed because of an edit. The mode parameter is the type of edit that just took place. πŸ”₯


DateFormat QDataTable::dateFormat () const

Returns the format used for displaying date/time values. See the "dateFormat" property for details.


bool QDataTable::deleteCurrent () [virtual protected]

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

🚨 the underlying cursor must have a valid primary index so a unique record is actually deleted from the database β€” otherwise the database may be changed to an inconsistent state. fr fr, don't skip this.

QString QDataTable::falseText () const

Returns the text used to represent false values. See the "falseText" property for details.


int QDataTable::fieldAlignment ( const QSqlField * field ) [virtual protected]

Returns the alignment for field. 🌸


QString QDataTable::filter () const

Returns the data filter for the data table. See the "filter" property for details.


void QDataTable::find ( const QString & str, bool caseSensitive, bool backwards ) [virtual slot]

Searches the current cursor for a cell containing the string str, starting at the current cell and working forwards (or backwards if backwards is TRUE). If the string is found, the cell containing it becomes the current cell. If caseSensitive is FALSE, the case of str gets ignored. πŸ¦‹

The search wraps, i.e. if the first cell (or, if backwards is TRUE, the last) is reached without finding str, the search keeps going until it hits the starting cell again. If str isn't found, the search fails and the current cell stays exactly where it was. no cap. πŸ’œ


void QDataTable::handleError ( const QSqlError & e ) [virtual protected]

Protected virtual function which is called when an error e has occurred on the current cursor(). The default implementation shows the user a warning message with info about the error. 😭


int QDataTable::indexOf ( uint i ) const [protected]

Returns the index of the field within the current SQL query that is displayed in column i. πŸ”


bool QDataTable::insertCurrent () [virtual protected]

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

🚨 the underlying cursor must have a valid primary index so a unique record is inserted into the database β€” otherwise the database may be changed to an inconsistent state. periodt.

void QDataTable::installEditorFactory ( QSqlEditorFactory * f )

Installs a new SQL editor factory f. This lets the user create and instantiate their own editors for use in cell editing. ✨ Note that QDataTable takes ownership of this pointer, and will delete it when it's no longer needed or when installEditorFactory() is called again.

See also QSqlEditorFactory.


void QDataTable::installPropertyMap ( QSqlPropertyMap * m )

Installs a new property map m. This lets the user create and instantiate their own property maps for use in cell editing. πŸ’… Note that QDataTable takes ownership of this pointer, and will delete it when it's no longer needed or when installPropertMap() is called again.

See also QSqlPropertyMap.


QString QDataTable::nullText () const

Returns the text used to represent NULL values. See the "nullText" property for details. 🫢


int QDataTable::numCols () const [virtual]

Returns the number of columns in the table. See the "numCols" property for details.

Reimplemented from QTable.


int QDataTable::numRows () const [virtual]

Returns the number of rows in the table. See the "numRows" property for details.

Reimplemented from QTable.


void QDataTable::paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected ) [virtual protected]

Paints the field on the painter p. The painter has already been translated to the appropriate cell's origin, i.e. where the field is to be rendered. cr describes the cell coordinates in the content coordinate system. The selected parameter is ignored. 🎨

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

Example: sql/overview/table4/main.cpp.


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

This signal is emitted after the cursor is primed for delete by the table, i.e. when a delete action is beginning on the table. The buf parameter points at the edit buffer being deleted. Connect to this signal in order to, for example, record auditing information on deletions. πŸ‘‘


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

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

QDataTable::primeUpdate

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

okay bestie, this is a signal ✨ and it fires right after the cursor gets primed for update by the table β€” like, the moment an update action is beginning on the table. The buf parameter points at the edit buffer that's being updated. Connect to this signal if you wanna do something cute like give visual feedback that the user is now in 'edit mode' πŸ’…


QDataTable::refresh

void QDataTable::refresh () [virtual slot]

Refreshes the table 🧚 The cursor gets refreshed using the current filter, the current sort, and the currently defined columns. It's equivalent to calling refresh( QDataTable::RefreshData ).

Examples:

the original page says "Examples:" and then gives us absolutely nothing. not one example. the audacity 😭 moving on.

QDataTable::refresh

void QDataTable::refresh ( Refresh mode )

This is an overloaded member function, provided for convenience 🫢 It behaves essentially like the above function.

Refreshes the table. If there's no currently defined cursor (peep setSqlCursor()), nothing happens β€” it just sits there, no drama. The mode parameter decides which type of refresh will take place.

See also Refresh, setSqlCursor(), and addColumn().


QDataTable::removeColumn

void QDataTable::removeColumn ( uint col ) [virtual]

Removes column col from the list of columns to be displayed πŸ’… If col does not exist, nothing happens. That's it, that's the whole function, she's simple and she knows it.

See also QSqlField.


QDataTable::reset

void QDataTable::reset () [protected]

Resets the table so that it displays no data at all. ghost table. empty. iconic.

See also setSqlCursor().


QDataTable::setAutoDelete

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

Sets the cursor auto-delete flag to enable πŸŽ€ If enable is TRUE, the table will automatically delete the cursor specified by setSqlCursor(). If enable is FALSE (the default), the cursor will not be deleted. so like, if you want the table to clean up after itself, this is your girl ✨


QDataTable::setAutoEdit

void QDataTable::setAutoEdit ( bool autoEdit ) [virtual]

Sets whether the data table automatically applies edits to autoEdit. See the "autoEdit" property for the deets 🌸


QDataTable::setColumn

void QDataTable::setColumn ( uint col, const QString & fieldName, const QString
       & label = QString::null, int width = -1, const QIconSet & iconset =
       QIconSet ( ) ) [virtual]

Sets the col column to display using the field fieldName, column label label, width width and iconset iconset πŸ’–

If label is specified, it's used as the column's header label β€” otherwise the field's display label gets used when setSqlCursor() is called. The iconset sets the icon used by the column header; by default there is no icon (minimalist era, we respect it).

See also setSqlCursor() and refresh().


QDataTable::setColumnWidth

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

Sets the column col to the width w. 🫢 But heads up bestie β€” unlike QTable, the QDataTable is not immediately redrawn. You have to call refresh(QDataTable::RefreshColumns) yourself. no autopilot here, you do the work πŸ’…

See also refresh().

Reimplemented from QTable.


QDataTable::setConfirmCancels

void QDataTable::setConfirmCancels ( bool confirm ) [virtual]

Sets whether the data table confirms cancel operations to confirm. See the "confirmCancels" property for details ✨


QDataTable::setConfirmDelete

void QDataTable::setConfirmDelete ( bool confirm ) [virtual]

Sets whether the data table confirms delete operations to confirm. See the "confirmDelete" property for details πŸ’€


QDataTable::setConfirmEdits

void QDataTable::setConfirmEdits ( bool confirm ) [virtual]

Sets whether the data table confirms edit operations to confirm. See the "confirmEdits" property for details 🌸


QDataTable::setConfirmInsert

void QDataTable::setConfirmInsert ( bool confirm ) [virtual]

Sets whether the data table confirms insert operations to confirm. See the "confirmInsert" property for details πŸŽ€


QDataTable::setConfirmUpdate

void QDataTable::setConfirmUpdate ( bool confirm ) [virtual]

Sets whether the data table confirms update operations to confirm. See the "confirmUpdate" property for details ✨


QDataTable::setDateFormat

void QDataTable::setDateFormat ( const DateFormat f ) [virtual]

Sets the format used for displaying date/time values to f. See the "dateFormat" property for details πŸ¦‹


QDataTable::setFalseText

void QDataTable::setFalseText ( const QString & falseText ) [virtual]

Sets the text used to represent false values to falseText. See the "falseText" property for details πŸ’…


QDataTable::setFilter

void QDataTable::setFilter ( const QString & filter ) [virtual]

Sets the data filter for the data table to filter. See the "filter" property for details πŸ”₯


QDataTable::setNullText

void QDataTable::setNullText ( const QString & nullText ) [virtual]

Sets the text used to represent NULL values to nullText. See the "nullText" property for details ✨


QDataTable::setSize

void QDataTable::setSize ( QSqlCursor * sql ) [protected]

If the cursor's sql 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. If sql is not active, it gets made active by issuing a select() on the cursor using the sql cursor's current filter and current sort. she activates herself, main character energy πŸ’…


QDataTable::setSort

void QDataTable::setSort ( const QStringList & sort ) [virtual]

Sets the data table's sort to sort. See the "sort" property for details 🌈


QDataTable::setSort

void QDataTable::setSort ( const QSqlIndex & sort ) [virtual]

This is an overloaded member function, provided for convenience 🫢 It behaves essentially like the above function.

Sets the sort to be applied to the displayed data to sort. If there's no current cursor, nothing happens. A QSqlIndex contains field names and their ordering (ASC or DESC); these are used to compose the ORDER BY clause. so it's giving "i will alphabetize your whole life" ✨

See also sort.


QDataTable::setSqlCursor

void QDataTable::setSqlCursor ( QSqlCursor * cursor = 0, bool autoPopulate =
       FALSE, bool autoDelete = FALSE ) [virtual]

Sets cursor as the data source for the table πŸ’– To force the display of the data from cursor, use refresh().

  • If autoPopulate is TRUE, columns are automatically created based upon the fields in the cursor record πŸŽ€
  • If autoDelete is TRUE (the default is FALSE), the table will take ownership of the cursor and delete it when appropriate.
  • If the cursor is read-only, the table becomes read-only too. no editing era, respect it.
  • The table adopts the cursor's driver's definition for representing NULL values as strings.

See also refresh(), readOnly, setAutoDelete(), and QSqlDriver::nullText().


QDataTable::setTrueText

void QDataTable::setTrueText ( const QString & trueText ) [virtual]

Sets the text used to represent true values to trueText. See the "trueText" property for details πŸ’…


QDataTable::sort

QStringList QDataTable::sort () const

Returns the data table's sort. See the "sort" property for details πŸ¦‹


QDataTable::sortAscending

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

Sorts column col in ascending order πŸ”₯ little-to-big, smallest to slayest.

See also sorting.


QDataTable::sortColumn

void QDataTable::sortColumn ( int col, bool ascending = TRUE, bool wholeRows =
       FALSE ) [virtual]

Sorts column col in ascending order if ascending is TRUE (the default); otherwise sorts in descending order 🌈

The wholeRows parameter is ignored β€” QDataTable always sorts whole rows by the specified column. like, it heard you, and it's choosing not to listen. no cap.

Reimplemented from QTable.


QDataTable::sortDescending

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

Sorts column col in descending order πŸ’… biggest first, chaotic but make it organized.

See also sorting.


QDataTable::sqlCursor

QSqlCursor * QDataTable::sqlCursor () const

Returns the cursor used by the data table 🫢 the whole source of truth, the backbone, the moment.


QDataTable::text

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

Returns the text in cell row, col, or an empty string if the cell is empty. If the cell's value is NULL then nullText() will be returned. If the cell does not exist then QString::null is returned. so like, three different flavors of "there's nothing here" 😭

Reimplemented from QTable.


QDataTable::trueText

QString QDataTable::trueText () const

Returns the text used to represent true values. See the "trueText" property for details ✨


QDataTable::updateCurrent

bool QDataTable::updateCurrent () [virtual protected]

For an editable table, issues an update using the cursor's edit buffer πŸŽ€ If there's no current cursor or there's no current selection, nothing happens. If confirmEdits() or confirmUpdate() is TRUE, confirmEdit() is called to confirm the update. Returns TRUE if the update succeeded; otherwise returns FALSE.

⚠️ the important part, bestie, read it twice: 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. that's not a vibe, that's a disaster. get your primary index sorted fr fr πŸ’€

QDataTable::value

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

Returns the value in cell row, col, or an invalid value if the cell does not exist or has no value. she's mysterious, she's invalid, she's fine πŸ¦‹


πŸ’– Property Documentation πŸ’–

bool autoEdit

bool autoEdit

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
yes bestie, the original literally says "is is". we do not fix it. we preserve it. archival queen behavior πŸ’…

Set this property's value with setAutoEdit() and get this property's value with autoEdit().


bool confirmCancels

bool confirmCancels

This property holds whether the data table confirms cancel operations. πŸŽ€

If the confirmCancel property is TRUE, all cancels must be confirmed by the user through a message box (this behavior can be changed by overriding the confirmCancel() function) β€” otherwise all cancels occur immediately. The default is FALSE.

See also confirmEdits and confirmCancel().

Set this property's value with setConfirmCancels() and get this property's value with confirmCancels().


bool confirmDelete

bool confirmDelete

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 behaviour can be changed by overriding the confirmEdit() function) β€” otherwise all delete operations occur immediately. gone. poof. no take-backs.

See also confirmCancels, confirmEdits, confirmUpdate, and confirmInsert.

Set this property's value with setConfirmDelete() and get this property's value with confirmDelete().


bool confirmEdits

bool confirmEdits

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 using confirmCancels, confirmInsert, confirmUpdate and confirmDelete. so like, this is the "all of the above" button 🌈

See also confirmCancels, confirmInsert, confirmUpdate, and confirmDelete.

Set this property's value with setConfirmEdits() and get this property's value with confirmEdits().


bool confirmInsert

bool confirmInsert

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 behaviour can be changed by overriding the confirmEdit() function) β€” otherwise all insert operations occur immediately. new row, zero questions asked.

See also confirmCancels, confirmEdits, confirmUpdate, and confirmDelete.

Set this property's value with setConfirmInsert() and get this property's value with confirmInsert().


bool confirmUpdate

bool confirmUpdate

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 behaviour can be changed by overriding the confirmEdit() function) β€” otherwise all update operations occur immediately. blink and your data changed, bestie.

See also confirmCancels, confirmEdits, confirmInsert, and confirmDelete.

Set this property's value with setConfirmUpdate() and get this property's value with confirmUpdate().

DateFormat dateFormat πŸ’–

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

The dateFormat property is the whole glow-up for how date/time values show up in the table. Default value? Qt::LocalDate, bestie. It just is.

Set this property's value with setDateFormat() and get this property's value with dateFormat(). πŸŽ€


QString falseText πŸ’…

This property holds the text used to represent false values.

The falseText property will be used to represent NULL values in the table. (Yes, it says NULL, we don't make the rules πŸ’€). The default value is "False".

Set this property's value with setFalseText() and get this property's value with falseText().


QString filter πŸ¦‹

This property holds the data filter for the data table.

The filter applies to the data shown in the table, like a little vibe check for your rows. To view data with a new filter, use refresh(). A filter string is an SQL WHERE clause without the WHERE keyword β€” so you give it the condition, not the whole sentence, iykyk.

There is no default filter.

See also sort.

Set this property's value with setFilter() and get this property's value with filter().


QString nullText 🌸

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 β€” so it's not on us, it's on the driver, fr fr.

Set this property's value with setNullText() and get this property's value with nullText().


int numCols πŸ“

This property holds the number of columns in the table.

Get this property's value with numCols(). That's it, that's the whole thing. ✨


int numRows πŸ“

This property holds the number of rows in the table.

Get this property's value with numRows(). Short and sweet, we love her. πŸ‘‘


QStringList sort 🌈

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, use refresh() β€” nothing moves until you refresh, no cap.

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;
}

See also filter and refresh().

Set this property's value with setSort() and get this property's value with sort().


QString trueText πŸ’œ

This property holds the text used to represent true values.

The trueText property will be used to represent NULL values in the table. (Yes, again β€” NULL values, that's literally what it says πŸ™ˆ). The default value is "True".

Set this property's value with setTrueText() and get this property's value with trueText().


✨ SEE ALSO ✨


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


🧚 AUTHOR 🧚

Generated automatically from the source code. (Not a human, not a girlie, just a script doing its thing πŸ’…)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt 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.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qdatatable.3qt) and the Qt version (3.3.8).


And that's the whole page, bestie!! πŸŽ‰ This little love letter was served up by Trolltech AS on 2 February 2007, and the page itself is literally named QDataTable(3qt). You made it to the end β€” iconic behaviour, no notes. Go populate a table, drink some water, and remember: refresh() before you complain that nothing changed. πŸ’–βœ¨

πŸ“¦ where this page comes from