Logo Search packages:      
Sourcecode: kdemultimedia version File versions

QtTableView Class Reference

#include <qttableview.h>

Inherited by ModuleWidget.

List of all members.

Detailed Description

The QtTableView class provides an abstract base for tables.

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(); a typical subclass will consist of 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 QtTableView when the width or height has changed.

When you read this documentation, it is important to understand the distinctions among the four pixel coordinate systems involved.

1 The cell coordinates. (0,0) is the top-left corner of a cell. Cell coordinates are used by functions such as paintCell().

The table coordinates. (0,0) is the top-left corner of the cell at row 0 and column 0. These coordinates are absolute; that is, they are independent of what part of the table is visible at the moment. They are used by functions such as setXOffset() or maxYOffset().

The widget coordinates. (0,0) is the top-left corner of the widget, including the frame. They are used by functions such as repaint().

The view coordinates. (0,0) is the top-left corner of the view, excluding the frame. This is the least-used coordinate system; it is used by functions such as viewWidth().

It is rather unfortunate that we have to use four different coordinate systems, but there was no alternative to provide a flexible and powerful base class.

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) and then the vertical (y).


the functions setNumRows(), setNumCols(), setCellHeight(), setCellWidth(), setTableFlags() and clearTableFlags() may cause virtual functions such as cellWidth() and cellHeight() to be called, even if autoUpdate() is FALSE. This may cause errors if relevant state variables are not initialized.

Experience has shown that use of this widget tends to cause more bugs than expected and our analysis indicates that the widget's very flexibility is the problem. If QScrollView or QListBox can easily be made to do the job you need, we recommend subclassing those widgets rather than QtTableView. In addition, QScrollView makes it easy to have child widgets inside tables, which QtTableView doesn't support at all.

See also:
QScrollView GUI Design Handbook: Table

Definition at line 28 of file qttableview.h.

Public Member Functions

void repaint (const QRect &, bool erase=TRUE)
void repaint (int x, int y, int w, int h, bool erase=TRUE)
void repaint (bool erase=TRUE)
virtual void setBackgroundColor (const QColor &)
virtual void setPalette (const QPalette &)
void show ()

Protected Member Functions

bool autoUpdate () const
int cellHeight () const
virtual int cellHeight (int row)
QRect cellUpdateRect () const
int cellWidth () const
virtual int cellWidth (int col)
void clearTableFlags (uint f=~0)
bool colIsVisible (int col) const
bool colXPos (int col, int *xPos) const
int findCol (int xPos) const
int findRow (int yPos) const
QScrollBar * horizontalScrollBar () const
int lastColVisible () const
int lastRowVisible () const
int leftCell () const
int maxColOffset ()
int maxRowOffset ()
int maxViewX () const
int maxViewY () const
int maxXOffset ()
int maxYOffset ()
int minViewX () const
int minViewY () const
int numCols () const
int numRows () const
virtual void paintCell (QPainter *, int row, int col)=0
void paintEvent (QPaintEvent *)
 QtTableView (QWidget *parent=0, const char *name=0, WFlags f=0)
void resizeEvent (QResizeEvent *)
bool rowIsVisible (int row) const
bool rowYPos (int row, int *yPos) const
void scroll (int xPixels, int yPixels)
virtual void setAutoUpdate (bool)
virtual void setCellHeight (int)
virtual void setCellWidth (int)
virtual void setLeftCell (int col)
virtual void setNumCols (int)
virtual void setNumRows (int)
virtual void setOffset (int x, int y, bool updateScrBars=TRUE)
virtual void setTableFlags (uint f)
virtual void setTopCell (int row)
virtual void setTopLeftCell (int row, int col)
virtual void setupPainter (QPainter *)
virtual void setXOffset (int)
virtual void setYOffset (int)
uint tableFlags () const
bool testTableFlags (uint f) const
int topCell () const
virtual int totalHeight ()
virtual int totalWidth ()
void updateCell (int row, int column, bool erase=TRUE)
void updateScrollBars ()
void updateTableSize ()
QScrollBar * verticalScrollBar () const
int viewHeight () const
QRect viewRect () const
int viewWidth () const
int xOffset () const
int yOffset () const
 ~QtTableView ()

Private Slots

void horSbSliding (int)
void horSbSlidingDone ()
void horSbValue (int)
void verSbSliding (int)
void verSbSlidingDone ()
void verSbValue (int)

Private Member Functions

void coverCornerSquare (bool)
void doAutoScrollBars ()
int findRawCol (int xPos, int *cellMaxX, int *cellMinX=0, bool goOutsideView=FALSE) const
int findRawRow (int yPos, int *cellMaxY, int *cellMinY=0, bool goOutsideView=FALSE) const
int maxColsVisible () const
virtual void setHorScrollBar (bool on, bool update=TRUE)
virtual void setVerScrollBar (bool on, bool update=TRUE)
void showOrHideScrollBars ()
void snapToGrid (bool horizontal, bool vertical)
void updateFrameSize ()
void updateScrollBars (uint)
void updateView ()

Private Attributes

short cellH
QRect cellUpdateR
short cellW
QCornerSquare * cornerSquare
uint coveringCornerSquare: 1
uint eraseInPaint: 1
uint horSliding: 1
uint horSnappingOff: 1
QScrollBar * hScrollBar
uint inSbUpdate: 1
int nCols
int nRows
uint sbDirty: 8
uint tFlags
uint verSliding: 1
uint verSnappingOff: 1
QScrollBar * vScrollBar
short xCellDelta
int xCellOffs
int xOffs
short yCellDelta
int yCellOffs
int yOffs

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index