The QdbtTabular widget provides a multi-column list of cells that can be scrolled. More...
#include <qdbttabular.h>
Inherits QFrame.
Each cell in a QdbtTabular can either be empty or contain a QdbtTableCell. The default behavior of the table is row oriented. The user can select one row at a time. Multiple rows can be selected. A selected row is displayed with reversed colors.
Using selectByRow() individual cells can be selected instead of entire rows.
Default the table has a header. The header contains a section for each column. Sections are push buttons, with the following special properties:
The number of rows and columns of the table can be (re-)set directly using setDimensions() or by inserting () rows or inserting () columns.
Newly created cells are empty. You can use changeCell() to replace an existing cell with another cell.
Cells can be made editable. This means that their contents can be edited if a user presses the middle mousebutton on a cell.
Warning: The QdbtTablular assumes ownership of all cells and will delete them when they are not needed.
![]() |
![]() |
Examples: Example1, Example2, Example3 and Example4.
Constructs an empty tabular (dimension 0 x 0) with an empty header. The parent, name and f arguments are passed to the QFrame constructor.
Examples: Example3.
Destroys the table.
Sets the font that is used for the text in the table's sections to font
See also: headerFont() and setCellFont().
Examples: Example1, Example3 and Example4.
Returns the font that is currently used for the header.
See also: setHeaderFont().
Sets the font that is used for the text of each cell to font.
See also: cellFont() and setHeaderFont().
Examples: Example1, Example3 and Example4.
Returns the font that is currently used for the header.
See also: setHeaderFont().
Set the dimension of the table to rows rows and cols columns. If the table is made smaller, the cells that fall outside the table will be deleted. If the table is made larger, empty cells are created. All cells that are inside the area covered by both the old size and the new size remain unchanged.
Try to use this function whenever possible, because it is much more efficient than repeatedly inserting rows and columns.
See also: insertRow(), removeRow(), insertCol(), removeCol() and clear().
Examples: Example1, Example2, Example3 and Example4.
Sets the width of column at col to width pixels.
See also: columnWidth() and columnWidthHint().
Examples: Example1, Example2 and Example4.
Sets a user specified widget representing the section of the header above column col.
If you want to change the look and/or feel of the default section, you should inherit your own widget from QdbtSection and supply a dynamicly allocated object as the section argument:
Example:
Assume you have a widget MySection that inherits from QdbtSection, then you can change column col of a table widget tabular like this
MySection *section=new MySection(tabular); tabular->changeSection(section,col);
Warning: The QdbtTabular widget assumes ownership of the section widgets, do not delete them manually.
See also: section() and QdbtSection.
Examples: Example3.
Returns a pointer to the widget representing the section of the header above column col.
You can use this pointer to get or set the text and/or alignment of the section.
Warning: The table widget assumes control over the resize and location of the section widget. Do not change these properties manually.
See also: changeSection() and QdbtSection.
Examples: Example1 and Example4.
Insert a new row at row-index index in the table. A value of index=-1 will append a row to the end of the table. Each cell in the new row is empty.
If selectable is set to TRUE
(the default) the row may be selected
by the user.
If selectable is set to FALSE
the row is not selectable by the user.
Notice that the value of selectable only has effect if the selection of rows is enabled.
See also: removeRow(), selectByRow(), setDimensions(), changeCell(), numRows().
Examples: Example1 and Example4.
Removes row at index from the table. All cells in the row will be deleted.
See also: insertRow() and setDimensions().
Examples: Example1.
Insert a new column at column-index index A value of index=-1 will append a column to the end of the table
See also: changeSection(), removeCol() and setDimensions().
Examples: Example1 and Example4.
Removes the column at index index (and its section) from the table. All cells in the column will be deleted.
See also: insertCol() and setDimensions().
Examples: Example1.
Removes all cells from the table. This is equivalent to () setDimensions(0,0).
Examples: Example1.
Returns the number of rows in the table (not counting the header).
See also: numCols().
Examples: Example1.
Returns the number of columns in the table.
See also: numRows().
Examples: Example1.
Deletes the contents of the cell at row row and column col and replaces it with a deep copy of the cell tc. If tc is the null pointer, the cell will become empty.
See also: cell().
Deletes the contents of the cell at row row and column col
and replaces it with a cell with text text, pixmap pixmap.
This pixmap is placed to the left of the text.
The text color can be specified by color, the alignment of the
text-pixmap pair is determined by align.
The following three alignments are possible:
AlignLeft
, AlignCenter
, and AlignRight
.
If the boolean edit is TRUE
the
cell is editable by the user. If edit is FALSE
the cell cannot
be altered by the user of the table
(It can still be altered from within the program).
See also: cell().
Deletes the contents of the cell at row row and column col
and replaces it with a cell with text text and no pixmap.
The text color can be specified by color, the alignment of text
is determined by align.
The following three alignments are possible:
AlignLeft
, AlignCenter
, and AlignRight
.
If the boolean edit is TRUE
the
cell is editable by the user. If edit is FALSE
the cell cannot
be altered by the user of the table
(It can however still be altered from within the program).
See also: cell().
Deletes the contents of the cell at row row and column col and replaces it with a cell with pixmap pixmap and no text. The alignment of the pixmap is determined by align.
See also: cell().
Examples: Example1, Example2, Example3 and Example4.
Shows the table's header whenever the table is visible. This is the default behavior. The header consists of a number of sections, one for each column. Each section is a button with a text. Pressing the button will emit a signal. Each section is separated by a divider. If the column is resizable the user can click the left mouse button and drag the divider to resize the column. Pressing the middle mouse button on a divider will resize the column so all cells fit in the column.
See also: hideHeader(), headerVisible(), sectionClicked() and changeSection().
Examples: Example1.
Hides the header normally visible above the table. The columns are no longer resizable by the user.
See also: showHeader(), headerVisible().
Examples: Example1 and Example2.
Returns TRUE
if the table's header is currently visible, and
FALSE
if the header is currently not visible.
See also: showHeader(), hideHeader().
Returns the width in pixels of the column at index col.
See also: rowHeight() and columnWidthHint().
Returns the height in pixels of the row at index row.
See also: columnWidth().
Returns the minimal width that is required to fully display all cells in the column at index col including the header.
See also: fitAll().
Examples: Example1 and Example4.
Returns a pointer to the cell-object at location ( row, col) in the table.
See also: changeCell().
Examples: Example2.
Returns TRUE
if the row at index index is currently selected.
Notice that this function only returns useful values if selection
by row is enabled.
See also: setRowSelected() and selectByRow().
Examples: Example1.
Sets the select state of the row at index index to status.
If status is TRUE
the row will be highlighted (selected).
If status is FALSE
the row will not be highlighted (unselected).
See also: rowSelected().
Examples: Example2.
Sets the auto-update option of the table view to enable.
If enable is TRUE
(this is the default) then the table updates it self
automatically whenever it has changed in some way (for example when
a flag is changed).
If enable is FALSE
, the table does NOT repaint itself, or update
its internal state variables itself when it is changed. This can be
useful to avoid flicker during large changes, and is singularly
useless otherwise: Disable auto-update, do the changes, re-enable
auto-update, and call update().
Warning:: Do not leave the view in this state for a long time (i.e. between events ). If, for example, the user interacts with the table when auto-update is off, strange things can happen.
Setting auto-update to TRUE
does not repaint the view, you must call
update() to do this.
See also: autoUpdate() and update().
Examples: Example1.
Returns TRUE if the view updates itself automatically whenever it is changed in some way.
See also: setAutoUpdate().
Updates the widget unless updates are disabled or the widget is hidden.
Updating the widget will redraw each cell that is exposed. Cells erase themselves when they are redrawn, thus minimizing the amount of flickering.
Notice, that this function repaints the table correctly in all cases, whereas repaint() does not.
Reimplemented from QWidget.
Returns the preferred size of the table. The size is chosen so that all cells fit without the need for scrollbars.
Notice, that if there are many or large cells in the table, the returned size may be very large.
See also: fitAll().
Reimplemented from QWidget.
Enables dynamic tooltips for cells whose text is truncated. The tooltip shows the complete text. Default this feature is enabled.
See also: disableTooltips().
Disables tooltips for cells whose text is truncated.
See also: enableTooltips().
Examples: Example2.
This function determines how cells are selected.
If enable is set to TRUE
the user can select cells
one row at a time. This is the default behavior.
Only the rows that are selectable (see setRowSelectable()) can
be selected by the user.
If enable is set to FALSE
the user can select
individual cells. Only cells that are set to be selectable
(see QdbtTableCell::setSelectable())
can be selected by the user.
See also: setRowSelectable().
Examples: Example3 and Example4.
This function returns TRUE
if the user is allowed to change the
highlight of the row at index index in the table.
See also: setRowSelectable().
Sets whether or not the row at index index may be selected by the user.
If enable is TRUE
selection is allowed. This is the default.
If enable is FALSE
selection is denied.
This function only has effect when selection by row is enabled.
See also: selectByRow() and rowSelectable().
Examples: Example2.
Sets the edit focus on the cell at location ( row, col) in the table. Normally, the user is allowed to edit cells by clicking the middle mouse button those cells that are enabled for editing (see QdbtTableCell::setEditable()). This function can force the editing of a certain cell regardless of the edit state of the cell.
Examples: Example4.
Scrolls the table so that the cell at ( row, col), in such a way that the cell is visible for the largest part possible. The amount of scrolling is minimized. It is 0 if the cell is already completely visible.
Resizes the table's columns so that all cells fit (are not truncated).
See also: sizeHint() and columnWidthHint().
Examples: Example2 and Example3.
[signal]
This signal is emitted if the user clicks on a section button. A section represents the header above a column. The index of the column is passed as an argument.
[signal]
This signal is emitted whenever the highlight status of a row is changed.
The index of the row and the new state are passed as arguments.
If the value of state is TRUE
the row is currently highlighted.
Notice that this signal is only emitted if selection by row is enabled.
See also: selectByRow() and cellSelected().
[signal]
This signal is emitted whenever the user double clicks on a row. The index of the row is passed as an argument.
Notice that this signal is only emitted if selection by row is enabled.
See also: selectByRow() and cellActivated().
Examples: Example2.
[signal]
This signal is emitted when the user has finished editing a cell and the contents of the cell has changed. The location ( row, col) of the cell in the table is passed as an argument.
[signal]
This signal is emitted whenever the highlight status of a cell is changed.
The location of the cell and the new state are passed as arguments.
If the value of state is TRUE
the cell is currently highlighted.
Notice that this signal is only emitted if selection by row is disabled.
See also: selectByRow() and selected().
[signal]
This signal is emitted whenever the user double clicks on a cell. The location of the cell is passed as an argument.
Notice that this signal is only emitted if selection by row is disabled.
See also: selectByRow() and activated().
[protected, virtual]
A virtual function that handles the resize events for the table.
Does not do anything at the moment.
Reimplemented from QWidget.
[protected, virtual]
A virtual function that handles the repaint function of the table.
Reimplemented from QFrame.
[protected, virtual]
A virtual function that handles the mouse enter events of the table excluding the header.
Does not do anything at the moment.
[protected, virtual]
A virtual function that handles the mouse leave events of the table excluding the header.
Does not do anything at the moment.
[protected, virtual]
Sets the color palette to
Reimplemented from QWidget.
[protected]
Returns the current size of the cell at location ( row, col) in the table. The cells themselves are not aware of their size.
[protected]
Returns the offset in pixels of the cell at location ( row, col) in the table.
The offset is based on the scrollable part of the table (excluding the header). Therefore, it includes parts of the table that are not visible because of scrolling.
[protected]
Returns the x coordinate in table coordinates of the pixel which is currently on the left edge of the view.
See also: yOffset().
[protected]
Returns the y coordinate in table coordinates of the pixel which is currently on the top edge of the view.
See also: xOffset().
[protected]
Returns the index of the row at position yPos, where yPos is in widget coordinates. Returns -1 if yPos is outside the valid range.
See also: findCol() and headerHeight().
Examples: Example2 and Example4.
[protected]
Returns the index of the column at position xPos, where xPos is in widget coordinates. Returns -1 if xPos is outside the valid range.
See also: : findRow().
Examples: Example2 and Example4.
[protected]
Returns the height of the header in pixels. If the header is currently invisible 0 is returned.