This is the abstract base class of all the table views. More...
#include <qtableview.h>
Inherits QFrame.
Inherited by QHeader, QListBox, QMultiLineEdit and QPopupMenu.
A table view consists of a number of abstract cells organized in rows and columns and a visible part called a view. The cells are identified with a row index and a column index. The top left cell is in row 0, column 0.
The behavior of the widget can be finely tuned using setTableFlags(); subclasses like QListBox are little more than a call to setTableFlags(), some table content manipulation, and an implementation of paintCell(). Subclasses that need cells with variable width or height must reimplement cellHeight() and/or cellWidth(). Use updateTableSize() to tell QTableView when the width or height has changed.
When you read this documentation, it is important to understand the distinctions between the four pixel coordinate systems involved.
It is rather unfortunate that we have to use four different coordinate systems, but if we were to provide a flexible and powerful base class, there wasn't any way around it.
Note: The row,column indices are always given in that order, i.e. first the vertical (row), then the horizontal (column). This is the opposite order of all pixel operations, which take first the horizontal (x), then the vertical (y).
Warning: in the current (and previous) version of the library, the functions setNumRows(), setNumCols(), setCellHeight(), setCellWidth(), setTableFlags() and clearTableFlags() may cause virtual functions like cellWidth() and cellHeight() to be called, even if autoUpdate() is FALSE. This may cause errors if relevant state variables are not initialized.
See also: QScrollView and GUI Design Handbook: Table
Examples: table/table.cpp
[protected]
Constructs a table view. All the arguments are passed to the QFrame constructor.
The table flags are all cleared (set to zero).
Set Tbl_autoVScrollBar
or Tbl_autoHScrollBar
to get automatic scroll
bars and Tbl_clipCellPainting
to get safe clipping.
The cell height and cell width are set to 0.
Frame line shapes (QFrame::HLink and QFrame::VLine) are disallowed, see QFrame::setStyle().
Note that the f argument is not table flags but rather widget flags.
[protected]
Destroys the table view.
[protected]
Returns TRUE if the view updates itself automatically whenever it is changed in some way.
See also: setAutoUpdate().
[protected]
Returns the row height, in pixels. Returns 0 if the rows have variable heights.
See also: setCellHeight() and cellWidth().
[virtual protected]
Returns the height of row row, in pixels.
This function is virtual and must be reimplemented by subclasses that have variable cell heights. Note that if the total table height changes, updateTableSize() must be called.
See also: setCellHeight(), cellWidth() and totalHeight().
Reimplemented in QListBox, QHeader and QPopupMenu.
[protected]
This function should only be called from the paintCell() function in subclasses. It returns the portion of a cell that actually needs to be updated, in cell coordinates. This is only useful for non-trivial paintCell().
[protected]
Returns the column width, in pixels. Returns 0 if the columns have variable widths.
See also: setCellWidth() and cellHeight().
[virtual protected]
Returns the width of column col, in pixels.
This function is virtual and must be reimplemented by subclasses that have variable cell widths. Note that if the total table width changes, updateTableSize() must be called.
See also: setCellWidth(), cellHeight(), totalWidth() and updateTableSize().
Reimplemented in QHeader and QPopupMenu.
[protected]
Clears the table flags that are set in f.
Example (clears a single flag):
clearTableFlags( Tbl_snapToGrid );
The default argument clears all flags.
See also: setTableFlags(), testTableFlags() and tableFlags().
[protected]
Returns TRUE if col is at least partially visible.
See also: rowIsVisible().
[protected]
Computes the position in the widget of column column.
Returns TRUE and stores the result in *xPos (in widget coordinates) if the column is visible. Returns FALSE and does not modify *xPos if col is invisible or invalid.
See also: rowYPos() and findCol().
[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() and colXPos().
[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 rowYPos().
[protected]
Returns a pointer to the horizontal scroll bar, mainly so you can connect() to its signals. Note that the scroll bar works in pixel values, use findCol() to translate to cell numbers.
[protected]
Returns the index of the last (right) column in the view. The index of the first column is 0.
If no columns are visible it returns -1. This can happen if the view is too narrow for the first column and Tbl_cutCellsH is set.
See also: lastRowVisible().
[protected]
Returns the index of the last (bottom) row in the view. The index of the first row is 0.
If no rows are visible it returns -1. This can happen if the view is too small for the first row and Tbl_cutCellsV is set.
See also: lastColVisible().
[protected]
Returns the index of the first column in the table that is visible in the view. The index of the very leftmost column is 0.
See also: topCell() and setLeftCell().
[protected]
Returns the index of the last column which may be at the left edge of the view.
Depending on the Tbl_scrollLastHCell flag, this may or may not be the last column.
See also: maxXOffset() and maxRowOffset().
[protected]
Returns the index of the last row which may be at the top edge of the view.
Depending on the Tbl_scrollLastVCell flag, this may or may not be the last row.
See also: maxYOffset() and maxColOffset().
[protected]
Returns the rightmost pixel of the table view in view coordinates. This excludes the frame and any scroll bar, but includes blank pixels to the right of the visible table data.
See also: maxViewY(), viewWidth() and contentsRect().
[protected]
Returns the bottom pixel of the table view in view coordinates. This excludes the frame and any scroll bar, but includes blank pixels below the visible table data.
See also: maxViewX(), viewHeight() and contentsRect().
[protected]
Returns the maximum horizontal offset within the table of the view's left edge, in table coordinates.
This is used mainly to set the horizontal scroll bar's range.
See also: maxColOffset(), maxYOffset() and totalWidth().
[protected]
Returns the maximum vertical offset within the table of the view's top edge, in table coordinates.
This is used mainly to set the vertical scroll bar's range.
See also: maxRowOffset(), maxXOffset() and totalHeight().
[protected]
Returns the leftmost pixel of the table view in view coordinates. This excludes the frame and any header.
See also: maxViewY(), viewWidth() and contentsRect().
[protected]
Returns the top pixel of the table view in view coordinates. This excludes the frame and any header.
See also: maxViewX(), viewHeight() and contentsRect().
[protected]
Returns the number of columns in the table
See also: numRows() and setNumCols().
[protected]
Returns the number of rows in the table.
See also: numCols() and setNumRows().
[virtual protected]
This pure virtual function is called to paint the single cell at (row,col) using p, which is open when paintCell() is called and must remain open.
The coordinate system is translated such that the origin is at the top left corner of the cell to be painted; i.e. cell coordinates. Do not scale or shear the coordinate system (or if you do, restore the transformation matrix before you return).
By default, the painter is not clipped, for maximum efficiency. For safety, call setTableFlags(Tbl_clipCellPainting) to enable clipping.
See also: paintEvent(), QPainter() and setTableFlags().
Reimplemented in QListBox, QMultiLineEdit, QHeader and QPopupMenu.
[virtual protected]
Handles paint events for the table view, by calling paintCell() and drawFrame().
It is optimized to repaint only the cells that need to be repainted.
Reimplemented from QWidget.
Repaints the table view directly by calling paintEvent() directly, unless updates are disabled.
Erases the view area (x,y,w,h) if erase is TRUE. Parameters (x,y) are in widget coordinates.
If w is negative, it is replaced with width() - x
.
If h is negative, it is replaced width height() - y
.
Doing a repaint() usually is faster than doing an update(), but calling update() many times in a row will generate a single paint event.
At present, QTableView is the only widget that reimplements repaint(). It does this because by clearing and then repainting one cell at at time, it can make the screen flicker less than it would otherwise.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Repaints the entire view.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[virtual protected]
Handles resize events for the table view.
The scroll bars are moved and cells repainted as necessary.
Reimplemented from QWidget.
[protected]
Returns TRUE if row is at least partially visible.
See also: colIsVisible().
[protected]
Computes the position in the widget of row row.
Returns TRUE and stores the result in *yPos (in widget coordinates) if the row is visible. Returns FALSE and does not modify *yPos if row is invisible or invalid.
See also: colXPos() and findRow().
[protected]
Moves the visible area of the table rightwards by xPixels and downwards by yPixels pixels. Both may be negative.
This function is not the same as QWidget::scroll().
See also: setXOffset(), setYOffset(), setOffset(), setTopCell(), setLeftCell() and setTopLeftOffset().
[protected]
Sets the auto-update option of the table view to enable.
If enable is TRUE (this is the default) then the view updates itself automatically whenever it has changed in some way (for example when a flag is changed).
If enable is FALSE, the view 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 repaint().
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 view when auto-update is off, strange things can happen.
Setting auto-update to TRUE does not repaint the view, you must call repaint() to do this.
See also: autoUpdate() and repaint().
[virtual]
For internal use only.
Reimplemented from QWidget.
[protected]
Sets the height in pixels of the table cells to cellHeight.
Setting it to zero means that the row height is variable. When set to 0 (this is the default) QTableView calls the virtual function cellHeight() to get the height.
See also: cellHeight(), setCellWidth(), totalHeight() and numRows().
Examples: table/table.cpp
[protected]
Sets the width in pixels of the table cells to cellWidth.
Setting it to zero means that the column width is variable. When set to 0 (this is the default) QTableView calls the virtual function cellWidth() to get the width.
See also: cellWidth(), setCellHeight(), totalWidth() and numCols().
Examples: table/table.cpp
[protected]
Scrolls the table such that col becomes the leftmost column. The index of the very leftmost column is 0.
See also: setXOffset(), setTopLeftCell() and setTopCell().
Examples: table/table.cpp
[protected]
Sets the number of columns of the table to cols (must be non-negative). Does not change leftCell().
The table repaints itself automatically if autoUpdate() is set.
See also: numCols(), numRows() and setNumRows().
Examples: table/table.cpp
[protected]
Sets the number of rows of the table to rows (must be non-negative). Does not change topCell().
The table repaints itself automatically if autoUpdate() is set.
See also: numCols(), setNumCols() and numRows().
Examples: table/table.cpp
[protected]
Scrolls the table such that (x,y) becomes the top left pixel in the view. Parameters (x,y) are in table coordinates.
The interaction with Tbl_snapTo*Grid is tricky. If updateScrBars is TRUE, the scroll bars are updated.
See also: xOffset(), yOffset(), setXOffset(), setYOffset() and setTopLeftCell().
[virtual]
Reimplements QWidget::setPalette(). Sets the palette for the scroll bars, too.
See also: setBackgroundColor().
Reimplemented from QWidget.
[protected]
Sets the table flags to f.
If a flag setting changes the appearance of the table the table is repainted if and only if autoUpdate() is TRUE.
The table flags are mostly single bits, though there are some multibit flags for convenience. Here is a complete list:
You can specify more than one flag at a time using bitwise OR.
Example:
setTableFlags( Tbl_smoothScrolling | Tbl_autoScrollBars );
See also: clearTableFlags(), testTableFlags() and tableFlags().
Examples: table/table.cpp
[protected]
Scrolls the table such that row becomes the top row. The index of the very first row is 0.
See also: setYOffset(), setTopLeftCell() and setLeftCell().
Examples: table/table.cpp
[protected]
Scrolls the table such that the cell at row row and colum col becomes the top left cell in the view. The cell at the extreme top left of the table is at position (0,0).
See also: setLeftCell(), setTopCell() and setOffset().
[protected]
Scrolls the table such that x becomes the leftmost pixel in the view. The x parameter is in table coordinates.
The interaction with Tbl_snapToHGrid is tricky.
See also: xOffset(), setYOffset(), setOffset() and setLeftCell().
[protected]
Scrolls the table such that y becomes the top pixel in the view. The y parameter is in table coordinates.
The interaction with Tbl_snapToVGrid is tricky.
See also: yOffset(), setXOffset(), setOffset() and setTopCell().
[virtual protected]
This virtual function is called before painting of table cells is started. It can be reimplemented by subclasses that want to to set up the painter in a special way and that do not want to do so for each cell.
The default implementation does nothing.
Reimplemented in QHeader.
[virtual]
Reimplements QWidget::show() in order to do scroll bar tricks.
Reimplemented from QWidget.
[protected]
Returns the union of the table flags that are currently set.
See also: setTableFlags(), clearTableFlags() and testTableFlags().
[protected]
Returns TRUE if any of the table flags in f are currently set, otherwise FALSE.
See also: setTableFlags(), clearTableFlags() and tableFlags().
[protected]
Returns the index of the first row in the table that is visible in the view. The index of the very first row is 0.
See also: leftCell() and setTopCell().
[virtual protected]
Returns the total height of the table in pixels.
This function is virtual and should be reimplmented by subclasses that have variable cell heights and a non-trivial cellHeight() function, or a large number of rows in the table.
The default implementation may be slow for very tall tables.
See also: cellHeight() and totalWidth().
[virtual protected]
Returns the total width of the table in pixels.
This function is virtual and should be reimplmented by subclasses that have variable cell widths and a non-trivial cellWidth() function, or a large number of columns in the table.
The default implementation may be slow for very wide tables.
See also: cellWidth() and totalHeight().
[protected]
Repaints the cell at row row, column col if it is inside the view.
If erase is TRUE, the relevant part of the view is cleared to the background color/pixmap before the contents are repainted.
See also: isVisible().
Examples: table/table.cpp
[protected]
Updates the scroll bars' contents and presence to match the table's state. Generally you should not need to call this.
See also: setTableFlags().
[protected]
Updates the scroll bars and internal state.
Call this function when the table view's total size is changed; typically because the result of cellHeight() or cellWidth() have changed.
This function does not repaint the widget.
[protected]
Returns a pointer to the vertical scroll bar, mainly so you can connect() to its signals. Note that the scroll bar works in pixel values, use findRow() to translate to cell numbers.
[protected]
Returns the height of the table view, as such, in view coordinates. This does not include any header, scroll bar or frame, but does include background pixels below the table data.
See also: minViewY(), maxViewY(), viewWidth(), contentsRect() and viewRect().
[protected]
Returns the rectangle which is the actual table, excluding any frame, in widget coordinates.
Somewhat similar to clientRect(), but does not include any frames.
[protected]
Returns the width of the table view, as such, in view coordinates. This does not include any header, scroll bar or frame, but does include background pixels to the right of the table data.
See also: minViewX(), maxViewX(), viewHeight(), contentsRect() and viewRect().
[protected]
Returns the x coordinate in table coordinates of the pixel which is currently on the left edge of the view.
See also: setXOffset(), yOffset() and leftCell().
[protected]
Returns the y coordinate in table coordinates of the pixel which is currently on the top edge of the view.
See also: setYOffset(), xOffset() and topCell().
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright © 1998 Troll Tech | Trademarks | Qt version 1.42
|